forked from hyperledger-iroha/iroha-javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
124 lines (116 loc) · 2.74 KB
/
index.ts
File metadata and controls
124 lines (116 loc) · 2.74 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/* eslint-disable no-console */
// for usage with grpc package use endpoint_grpc_pb file
import grpc from '@grpc/grpc-js'
import {
QueryService_v1Client as QueryService,
CommandService_v1Client as CommandService
} from '../lib/proto/endpoint_grpc_pb'
import commands from '../lib/commands'
import queries from '../lib/queries'
const IROHA_ADDRESS = 'localhost:50051'
const adminPriv =
'f101537e319568c765b2cc89698325604991dca57b9716b58016b253506cab70'
const commandService = new CommandService(
IROHA_ADDRESS,
grpc.credentials.createInsecure()
)
const queryService = new QueryService(
IROHA_ADDRESS,
grpc.credentials.createInsecure()
)
queries.fetchCommits(
{
privateKey: adminPriv,
creatorAccountId: 'admin@test',
queryService,
timeoutLimit: 5000
},
(block) => console.log('fetchCommits new block:', block),
(error) => console.error('fetchCommits failed:', error.stack)
)
Promise.all([
commands.setAccountDetail({
privateKeys: [adminPriv],
creatorAccountId: 'admin@test',
quorum: 1,
commandService,
timeoutLimit: 5000
}, {
accountId: 'admin@test',
key: 'jason',
value: 'statham'
}),
queries.getAccount({
privateKey: adminPriv,
creatorAccountId: 'admin@test',
queryService,
timeoutLimit: 5000
}, {
accountId: 'admin@test'
}),
queries.getAccountDetail({
privateKey: adminPriv,
creatorAccountId: 'admin@test',
queryService,
timeoutLimit: 5000
}, {
accountId: 'admin@test',
key: 'jason',
writer: 'admin@test',
pageSize: 1,
paginationKey: 'jason',
paginationWriter: 'admin@test'
}),
queries.getSignatories({
privateKey: adminPriv,
creatorAccountId: 'admin@test',
queryService,
timeoutLimit: 5000
}, {
accountId: 'admin@test'
}),
queries.getRoles({
privateKey: adminPriv,
creatorAccountId: 'admin@test',
queryService,
timeoutLimit: 5000
}),
queries.getAccount({
privateKey: adminPriv,
creatorAccountId: 'admin@test',
queryService,
timeoutLimit: 5000
}, {
accountId: 'admin@test'
}),
queries.getAccountTransactions({
privateKey: adminPriv,
creatorAccountId: 'admin@test',
queryService,
timeoutLimit: 5000
}, {
accountId: 'admin@test',
pageSize: 5,
firstTxHash: undefined,
firstTxTime: undefined,
lastTxTime: undefined,
firstTxHeight: undefined,
lastTxHeight: undefined,
ordering: {
field: undefined,
direction: undefined
}
}),
queries.getAccountAssets({
privateKey: adminPriv,
creatorAccountId: 'admin@test',
queryService,
timeoutLimit: 5000
}, {
accountId: 'admin@test',
pageSize: 100,
firstAssetId: undefined
})
])
.then(a => console.log(a))
.catch(e => console.error(e))