-
Notifications
You must be signed in to change notification settings - Fork 6
/
getPI.js
27 lines (24 loc) · 862 Bytes
/
getPI.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const BusinessNetworkConnection = require('composer-client').BusinessNetworkConnection
const Table = require('cli-table2')
const getPI = (async function(){
try {
this.bizNetworkConnection = new BusinessNetworkConnection()
let connection = await this.bizNetworkConnection.connect('admin@land-registry')
let registry = await this.bizNetworkConnection.getParticipantRegistry('org.acme.landregistry.PrivateIndividual')
const privateId = process.argv.slice(2)[0]
if( !privateId ){
throw 'No id was specified!'
}
const private = await registry.get(privateId)
let table = new Table({
head: ['ID', 'Name', 'Address', 'Balance']
})
table.push([private.id, private.name, private.address, private.balance])
console.log(table.toString())
process.exit()
} catch( error ){
console.log(error)
process.exit()
}
})()
module.exports = getPI