-
Notifications
You must be signed in to change notification settings - Fork 6
/
getREAgents.js
32 lines (28 loc) · 976 Bytes
/
getREAgents.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
28
29
30
31
32
const BusinessNetworkConnection = require('composer-client').BusinessNetworkConnection
const Table = require('cli-table2')
const getREAgents = (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.RealEstateAgent')
let resources = await registry.getAll()
let table = new Table({
head: ['ID', 'Name', 'Balance', 'Fee rate']
})
let arrayLength = resources.length
for(let i = 0; i < arrayLength; i++) {
let tableLine = []
tableLine.push(resources[i].id)
tableLine.push(resources[i].name)
tableLine.push(resources[i].balance)
tableLine.push(resources[i].feeRate)
table.push(tableLine)
}
console.log(table.toString())
process.exit()
} catch(error) {
console.log(error)
process.exit()
}
}())
module.exports = getREAgents