-
Notifications
You must be signed in to change notification settings - Fork 6
/
createRE.js
34 lines (28 loc) · 1.08 KB
/
createRE.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
33
34
const BusinessNetworkConnection = require('composer-client').BusinessNetworkConnection
const createRE = (async function(){
try {
this.bizNetworkConnection = new BusinessNetworkConnection()
let connection = await this.bizNetworkConnection.connect('admin@land-registry')
const args = process.argv.slice(2)
const reId = args.shift()
const address = args.shift()
const squareMeters = args.shift()
const price = args.shift()
const ownerId = args.shift()
let factory = connection.getFactory()
let re = factory.newResource('org.acme.landregistry', 'RealEstate', reId)
re.address = address
re.squareMeters = parseFloat(squareMeters)
re.price = parseFloat(price)
this.reRegistry = await this.bizNetworkConnection.getAssetRegistry('org.acme.landregistry.RealEstate')
let ownerRelationship = factory.newRelationship('org.acme.landregistry', 'PrivateIndividual', ownerId)
re.owner = ownerRelationship
await this.reRegistry.add(re)
console.log('Real Estate asset created!')
process.exit()
}catch( err ){
console.log(err)
process.exit()
}
})()
module.exports = createRE