-
Notifications
You must be signed in to change notification settings - Fork 2
/
v060-get-cluster-info.js
71 lines (56 loc) · 2.48 KB
/
v060-get-cluster-info.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
require('dotenv').config()
const { getClient } = require('@phala/sdk')
const argv = require('arg')({
'--ws': String,
'--clusterId': String,
'--worker': String,
'--pruntimeURL': String
})
async function main() {
const ws = argv['--ws'] || process.env.ENDPOINT
if (!ws) {
throw new Error('No ws endpoint specified')
}
const clusterId = argv['--clusterId']
const workerId = argv['--worker']
const pruntimeURL = argv['--pruntimeURL']
const connectionOptions = {}
if (clusterId) {
connectionOptions.clusterId = clusterId
}
if (workerId) {
connectionOptions.workerId = workerId
} else if (pruntimeURL) {
connectionOptions.pruntimeURL = pruntimeURL
}
const registry = await getClient({
transport: ws,
...connectionOptions
})
console.log('Connected via', ws)
console.log('Cluster ID:', registry.clusterId)
console.log('Worker ID:', registry.remotePubkey)
console.log('Worker Endpoint:', registry.pruntimeURL)
console.log('')
console.log('System Contract ID:', registry.systemContract.address.toHex())
const { output: systemVersionQuery } = await registry.systemContract.q.system.version()
console.log('System Contract Version:', systemVersionQuery.asOk.toJSON())
console.log('')
const loggerInfo = await registry.loggerContract.getInfo()
const loggerContractInfo = await registry.phactory.getContractInfo({ contracts: [
registry.loggerContract.address.toHex()
]})
console.log('PinkLogger Contract ID:', registry.loggerContract.address.toHex())
console.log('PinkLogger Running State:', loggerContractInfo.contracts[0].sidevm.state)
console.log('PinkLogger SideVM Start Time:', loggerContractInfo.contracts[0].sidevm.startTime)
console.log('PinkLogger Info:', loggerInfo)
console.log('')
// const { output: jsDelegateQuery } = await registry.systemContract.query['system::getDriver'](cert.address, { cert }, 'JsDelegate')
const { output: jsDelegateQuery } = await registry.systemContract.q.system.getDriver({ args: ['JsDelegate'] })
console.log('JsDelegate Contract ID:', jsDelegateQuery.asOk.toHex())
console.log('')
// const { output: sidevmOperationQuery } = await registry.systemContract.query['system::getDriver'](cert.address, { cert }, 'SidevmOperation')
const { output: sidevmOperationQuery } = await registry.systemContract.q.system.getDriver({ args: ['SidevmOperation'] })
console.log('SidevmOperation Contract ID:', sidevmOperationQuery.asOk.toHex())
}
main().catch(console.error).finally(() => process.exit())