github.com/muhammedhassanm/blockchain@v0.0.0-20200120143007-697261defd4d/build-blockchain-insurance-app-master/web/www/blockchain/policePeer.js (about) 1 'use strict'; 2 3 import config from './config'; 4 import { wrapError } from './utils'; 5 import { policeClient as client, isReady } from './setup'; 6 7 export async function listTheftClaims() { 8 if (!isReady()) { 9 return; 10 } 11 try { 12 const theftClaims = await query('theft_claim_ls'); 13 return theftClaims; 14 } catch (e) { 15 throw wrapError(`Error getting theft claims ${e.message}`, e); 16 } 17 } 18 19 export async function processTheftClaim( 20 { uuid, contractUuid, isTheft, fileReference }) { 21 if (!isReady()) { 22 return; 23 } 24 try { 25 await invoke('theft_claim_process', 26 { uuid, contractUuid, isTheft, fileReference }); 27 } catch (e) { 28 throw wrapError(`Error processing theft claim ${e.message}`, e); 29 } 30 } 31 32 export const on = client.on.bind(client); 33 export const once = client.once.bind(client); 34 export const addListener = client.addListener.bind(client); 35 export const prependListener = client.prependListener.bind(client); 36 export const removeListener = client.removeListener.bind(client); 37 38 function invoke(fcn, ...args) { 39 return client.invoke( 40 config.chaincodeId, config.chaincodeVersion, fcn, ...args); 41 } 42 43 function query(fcn, ...args) { 44 return client.query( 45 config.chaincodeId, config.chaincodeVersion, fcn, ...args); 46 }