wowok 1.2.10 → 1.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/demand.ts +85 -98
- package/src/entity.ts +35 -35
- package/src/guard.ts +15 -15
- package/src/machine.ts +150 -174
- package/src/passport.ts +34 -38
- package/src/permission.ts +157 -89
- package/src/progress.ts +118 -118
- package/src/protocol.ts +28 -31
- package/src/repository.ts +147 -160
- package/src/resource.ts +43 -45
- package/src/reward.ts +108 -119
- package/src/service.ts +338 -364
- package/src/utils.ts +9 -5
- package/src/vote.ts +139 -157
- package/src/wowok.ts +19 -23
package/src/machine.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { TransactionBlock,
|
|
1
|
+
import { Transaction as TransactionBlock, TransactionObjectArgument, type TransactionResult } from '@mysten/sui/transactions';
|
|
2
2
|
import { BCS } from '@mysten/bcs';
|
|
3
3
|
import { Protocol, FnCallType, PermissionObject, RepositoryObject, PassportObject, MachineObject, MachineAddress, GuardObject, TxbObject} from './protocol';
|
|
4
4
|
import { IsValidInt, Bcs, array_unique, IsValidArray, IsValidAddress, IsValidName, IsValidName_AllowEmpty,
|
|
5
|
-
IsValidEndpoint,
|
|
5
|
+
IsValidEndpoint, IsValidDesription,
|
|
6
6
|
IsValidUintLarge} from './utils'
|
|
7
7
|
import { Permission, PermissionIndexType } from './permission';
|
|
8
8
|
import { Errors, ERROR} from './exception'
|
|
@@ -27,24 +27,24 @@ export interface Machine_Node {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
export class Machine {
|
|
30
|
-
protected
|
|
30
|
+
protected txb;
|
|
31
31
|
protected object : TxbObject;
|
|
32
|
-
protected permission;
|
|
32
|
+
protected permission: TxbObject;
|
|
33
33
|
|
|
34
34
|
get_object() { return this.object }
|
|
35
35
|
|
|
36
|
-
static From(
|
|
37
|
-
let d = new Machine(
|
|
38
|
-
d.object = Protocol.TXB_OBJECT(
|
|
36
|
+
static From(txb:TransactionBlock, permission:PermissionObject, object:TxbObject) : Machine {
|
|
37
|
+
let d = new Machine(txb, permission)
|
|
38
|
+
d.object = Protocol.TXB_OBJECT(txb, object)
|
|
39
39
|
return d
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
private constructor(
|
|
43
|
-
this.
|
|
42
|
+
private constructor(txb:TransactionBlock, permission:PermissionObject) {
|
|
43
|
+
this.txb = txb;
|
|
44
44
|
this.permission = permission;
|
|
45
45
|
this.object = '';
|
|
46
46
|
}
|
|
47
|
-
static New(
|
|
47
|
+
static New(txb:TransactionBlock, permission:PermissionObject, description:string, endpoint?:string|null|undefined, passport?:PassportObject) : Machine {
|
|
48
48
|
if (!Protocol.IsValidObjects([permission])) {
|
|
49
49
|
ERROR(Errors.IsValidObjects, 'permission')
|
|
50
50
|
}
|
|
@@ -55,19 +55,18 @@ export class Machine {
|
|
|
55
55
|
ERROR(Errors.IsValidEndpoint)
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
let m = new Machine(
|
|
59
|
-
let
|
|
60
|
-
let ep = endpoint? txb.pure(Bcs.getInstance().ser(ValueType.TYPE_OPTION_STRING, endpoint)) : OptionNone(txb);
|
|
58
|
+
let m = new Machine(txb, permission);
|
|
59
|
+
let ep = txb.pure.option('string', endpoint ? endpoint : undefined);
|
|
61
60
|
|
|
62
61
|
if (passport) {
|
|
63
62
|
m.object = txb.moveCall({
|
|
64
|
-
target:
|
|
65
|
-
arguments:[passport, txb.pure(description), ep, Protocol.TXB_OBJECT(txb, permission)],
|
|
63
|
+
target:Protocol.Instance().MachineFn('new_with_passport') as FnCallType,
|
|
64
|
+
arguments:[passport, txb.pure.string(description), ep, Protocol.TXB_OBJECT(txb, permission)],
|
|
66
65
|
})
|
|
67
66
|
} else {
|
|
68
67
|
m.object = txb.moveCall({
|
|
69
|
-
target:
|
|
70
|
-
arguments:[txb.pure(description), ep, Protocol.TXB_OBJECT(txb, permission)],
|
|
68
|
+
target:Protocol.Instance().MachineFn('new') as FnCallType,
|
|
69
|
+
arguments:[txb.pure.string(description), ep, Protocol.TXB_OBJECT(txb, permission)],
|
|
71
70
|
})
|
|
72
71
|
}
|
|
73
72
|
return m
|
|
@@ -93,25 +92,24 @@ export class Machine {
|
|
|
93
92
|
}
|
|
94
93
|
|
|
95
94
|
let new_nodes: TxbObject[] = [];
|
|
96
|
-
let txb = this.protocol.CurrentSession();
|
|
97
95
|
nodes.forEach((node) => {
|
|
98
|
-
let n = txb.moveCall({
|
|
99
|
-
target:
|
|
100
|
-
arguments:[txb.pure(node.name)]
|
|
96
|
+
let n = this.txb.moveCall({
|
|
97
|
+
target:Protocol.Instance().MachineFn('node_new') as FnCallType,
|
|
98
|
+
arguments:[this.txb.pure.string(node.name)]
|
|
101
99
|
});
|
|
102
100
|
node.pairs.forEach((pair) => {
|
|
103
|
-
let threshold =
|
|
101
|
+
let threshold = this.txb.pure.option('u32', pair?.threshold);
|
|
104
102
|
|
|
105
103
|
pair.forwards.forEach((forward) => {
|
|
106
|
-
txb.moveCall({ // add forward
|
|
107
|
-
target:
|
|
108
|
-
arguments:[n, txb.pure(pair.prior_node), txb.pure(forward.name), threshold, this.forward(forward)]
|
|
104
|
+
this.txb.moveCall({ // add forward
|
|
105
|
+
target:Protocol.Instance().MachineFn('forward_add') as FnCallType,
|
|
106
|
+
arguments:[n, this.txb.pure.string(pair.prior_node), this.txb.pure.string(forward.name), threshold, this.forward(forward)]
|
|
109
107
|
});
|
|
110
108
|
});
|
|
111
109
|
if (pair.forwards.length === 0) {
|
|
112
|
-
txb.moveCall({ // add forward
|
|
113
|
-
target:
|
|
114
|
-
arguments:[n, txb.pure(pair.prior_node), threshold]
|
|
110
|
+
this.txb.moveCall({ // add forward
|
|
111
|
+
target:Protocol.Instance().MachineFn('forward_add_none') as FnCallType,
|
|
112
|
+
arguments:[n, this.txb.pure.string(pair.prior_node), threshold]
|
|
115
113
|
});
|
|
116
114
|
}
|
|
117
115
|
});
|
|
@@ -121,22 +119,20 @@ export class Machine {
|
|
|
121
119
|
}
|
|
122
120
|
|
|
123
121
|
forward(forward:Machine_Forward) : TransactionResult {
|
|
124
|
-
const txb = this.protocol.CurrentSession();
|
|
125
|
-
|
|
126
122
|
let weight = forward?.weight ? forward.weight : 1;
|
|
127
|
-
let perm =
|
|
128
|
-
let namedOperator = forward?.namedOperator ? txb.pure(forward.namedOperator) : txb.pure('');
|
|
123
|
+
let perm = this.txb.pure.option('u64', forward?.permission);
|
|
124
|
+
let namedOperator = forward?.namedOperator ? this.txb.pure.string(forward.namedOperator) : this.txb.pure.string('');
|
|
129
125
|
let f:any;
|
|
130
126
|
|
|
131
127
|
if (forward?.guard) {
|
|
132
|
-
f = txb.moveCall({
|
|
133
|
-
target:
|
|
134
|
-
arguments:[namedOperator, txb.pure(weight), txb.object(Protocol.TXB_OBJECT(txb, forward.guard)), perm]
|
|
128
|
+
f = this.txb.moveCall({
|
|
129
|
+
target:Protocol.Instance().MachineFn('forward') as FnCallType,
|
|
130
|
+
arguments:[namedOperator, this.txb.pure.u16(weight), this.txb.object(Protocol.TXB_OBJECT(this.txb, forward.guard)), perm]
|
|
135
131
|
});
|
|
136
132
|
} else {
|
|
137
|
-
f = txb.moveCall({
|
|
138
|
-
target:
|
|
139
|
-
arguments:[namedOperator, txb.pure(weight), perm]
|
|
133
|
+
f = this.txb.moveCall({
|
|
134
|
+
target:Protocol.Instance().MachineFn('forward2') as FnCallType,
|
|
135
|
+
arguments:[namedOperator, this.txb.pure.u16(weight), perm]
|
|
140
136
|
});
|
|
141
137
|
}
|
|
142
138
|
return f
|
|
@@ -144,22 +140,17 @@ export class Machine {
|
|
|
144
140
|
|
|
145
141
|
// move MachineNodeObject to the machine from signer-owned MachineNode object
|
|
146
142
|
add_node2(nodes:TxbObject[], passport?:PassportObject) {
|
|
147
|
-
if (nodes.length === 0)
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
let txb = this.protocol.CurrentSession();
|
|
152
|
-
let n: TransactionResult[] = nodes.map((v)=>Protocol.TXB_OBJECT(txb, v));
|
|
153
|
-
|
|
143
|
+
if (nodes.length === 0) return;
|
|
144
|
+
let n: TransactionObjectArgument[] = nodes.map((v)=>Protocol.TXB_OBJECT(this.txb, v));
|
|
154
145
|
if (passport) {
|
|
155
|
-
txb.moveCall({ // add node
|
|
156
|
-
target:
|
|
157
|
-
arguments:[passport, Protocol.TXB_OBJECT(txb, this.object), txb.makeMoveVec({
|
|
146
|
+
this.txb.moveCall({ // add node
|
|
147
|
+
target:Protocol.Instance().MachineFn('node_add_with_passport') as FnCallType,
|
|
148
|
+
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.makeMoveVec({elements:n}), Protocol.TXB_OBJECT(this.txb, this.permission)]
|
|
158
149
|
});
|
|
159
150
|
} else {
|
|
160
|
-
txb.moveCall({ // add node
|
|
161
|
-
target:
|
|
162
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.makeMoveVec({
|
|
151
|
+
this.txb.moveCall({ // add node
|
|
152
|
+
target:Protocol.Instance().MachineFn('node_add') as FnCallType,
|
|
153
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.makeMoveVec({elements:n}), Protocol.TXB_OBJECT(this.txb, this.permission)]
|
|
163
154
|
});
|
|
164
155
|
}
|
|
165
156
|
}
|
|
@@ -168,17 +159,17 @@ export class Machine {
|
|
|
168
159
|
if (!IsValidName(node_name)) {
|
|
169
160
|
ERROR(Errors.IsValidName, 'fetch_node');
|
|
170
161
|
}
|
|
171
|
-
|
|
162
|
+
|
|
172
163
|
if (passport) {
|
|
173
|
-
return txb.moveCall({
|
|
174
|
-
target:
|
|
175
|
-
arguments:[passport, Protocol.TXB_OBJECT(txb, this.object), txb.pure(node_name),
|
|
176
|
-
Protocol.TXB_OBJECT(txb, this.permission)],
|
|
164
|
+
return this.txb.moveCall({
|
|
165
|
+
target:Protocol.Instance().MachineFn('node_fetch_with_passport') as FnCallType,
|
|
166
|
+
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(node_name),
|
|
167
|
+
Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
177
168
|
});
|
|
178
169
|
} else {
|
|
179
|
-
return txb.moveCall({
|
|
180
|
-
target:
|
|
181
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(node_name), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
170
|
+
return this.txb.moveCall({
|
|
171
|
+
target:Protocol.Instance().MachineFn('node_fetch') as FnCallType,
|
|
172
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(node_name), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
182
173
|
});
|
|
183
174
|
}
|
|
184
175
|
}
|
|
@@ -187,21 +178,19 @@ export class Machine {
|
|
|
187
178
|
if (!IsValidName(node_name)) ERROR(Errors.IsValidName, 'rename_node');
|
|
188
179
|
if (!IsValidName(new_name)) ERROR(Errors.IsValidName, 'rename_node');
|
|
189
180
|
|
|
190
|
-
let txb = this.protocol.CurrentSession();
|
|
191
|
-
|
|
192
181
|
if (passport) {
|
|
193
|
-
txb.moveCall({
|
|
194
|
-
target:
|
|
195
|
-
arguments:[passport, Protocol.TXB_OBJECT(txb, this.object),
|
|
196
|
-
txb.pure(node_name), txb.pure(new_name),
|
|
197
|
-
Protocol.TXB_OBJECT(txb, this.permission)],
|
|
182
|
+
this.txb.moveCall({
|
|
183
|
+
target:Protocol.Instance().MachineFn('node_rename_with_passport') as FnCallType,
|
|
184
|
+
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object),
|
|
185
|
+
this.txb.pure.string(node_name), this.txb.pure.string(new_name),
|
|
186
|
+
Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
198
187
|
});
|
|
199
188
|
} else {
|
|
200
|
-
txb.moveCall({
|
|
201
|
-
target:
|
|
202
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object),
|
|
203
|
-
txb.pure(node_name), txb.pure(new_name),
|
|
204
|
-
Protocol.TXB_OBJECT(txb, this.permission)],
|
|
189
|
+
this.txb.moveCall({
|
|
190
|
+
target:Protocol.Instance().MachineFn('node_rename') as FnCallType,
|
|
191
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object),
|
|
192
|
+
this.txb.pure.string(node_name), this.txb.pure.string(new_name),
|
|
193
|
+
Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
205
194
|
});
|
|
206
195
|
}
|
|
207
196
|
}
|
|
@@ -213,35 +202,33 @@ export class Machine {
|
|
|
213
202
|
if (!IsValidArray(nodes_name, IsValidName)) {
|
|
214
203
|
ERROR(Errors.IsValidArray, 'nodes_name')
|
|
215
204
|
}
|
|
216
|
-
|
|
217
|
-
let txb = this.protocol.CurrentSession();
|
|
205
|
+
|
|
218
206
|
if (passport) {
|
|
219
|
-
txb.moveCall({
|
|
220
|
-
target:
|
|
221
|
-
arguments:[passport, Protocol.TXB_OBJECT(txb, this.object), txb.pure(Bcs.getInstance().ser(ValueType.TYPE_VEC_STRING, nodes_name)),
|
|
222
|
-
txb.pure(bTransferMyself
|
|
207
|
+
this.txb.moveCall({
|
|
208
|
+
target:Protocol.Instance().MachineFn('node_remove_with_passport') as FnCallType,
|
|
209
|
+
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure(Bcs.getInstance().ser(ValueType.TYPE_VEC_STRING, nodes_name)),
|
|
210
|
+
this.txb.pure.bool(bTransferMyself), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
223
211
|
});
|
|
224
212
|
} else {
|
|
225
|
-
txb.moveCall({
|
|
226
|
-
target:
|
|
227
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(Bcs.getInstance().ser(ValueType.TYPE_VEC_STRING, nodes_name)),
|
|
213
|
+
this.txb.moveCall({
|
|
214
|
+
target:Protocol.Instance().MachineFn('node_remove') as FnCallType,
|
|
215
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure(Bcs.getInstance().ser(ValueType.TYPE_VEC_STRING, nodes_name)),
|
|
216
|
+
this.txb.pure.bool(bTransferMyself), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
228
217
|
});
|
|
229
218
|
}
|
|
230
219
|
}
|
|
231
220
|
|
|
232
221
|
destroy() {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
arguments: [Protocol.TXB_OBJECT(txb, this.object)],
|
|
222
|
+
this.txb.moveCall({
|
|
223
|
+
target:Protocol.Instance().MachineFn('destroy') as FnCallType,
|
|
224
|
+
arguments: [Protocol.TXB_OBJECT(this.txb, this.object)],
|
|
237
225
|
})
|
|
238
226
|
}
|
|
239
227
|
|
|
240
228
|
launch() : MachineAddress {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object)],
|
|
229
|
+
return this.txb.moveCall({
|
|
230
|
+
target:Protocol.Instance().MachineFn('create') as FnCallType,
|
|
231
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object)],
|
|
245
232
|
})
|
|
246
233
|
}
|
|
247
234
|
|
|
@@ -250,30 +237,28 @@ export class Machine {
|
|
|
250
237
|
ERROR(Errors.IsValidDesription)
|
|
251
238
|
}
|
|
252
239
|
|
|
253
|
-
let txb = this.protocol.CurrentSession();
|
|
254
240
|
if (passport) {
|
|
255
|
-
txb.moveCall({
|
|
256
|
-
target:
|
|
257
|
-
arguments:[passport, Protocol.TXB_OBJECT(txb, this.object), txb.pure(description), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
241
|
+
this.txb.moveCall({
|
|
242
|
+
target:Protocol.Instance().MachineFn('description_set_with_passport') as FnCallType,
|
|
243
|
+
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(description), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
258
244
|
})
|
|
259
245
|
} else {
|
|
260
|
-
txb.moveCall({
|
|
261
|
-
target:
|
|
262
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(description), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
246
|
+
this.txb.moveCall({
|
|
247
|
+
target:Protocol.Instance().MachineFn('description_set') as FnCallType,
|
|
248
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(description), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
263
249
|
})
|
|
264
250
|
}
|
|
265
251
|
}
|
|
266
252
|
add_repository(repository:RepositoryObject, passport?:PassportObject) {
|
|
267
|
-
let txb = this.protocol.CurrentSession();
|
|
268
253
|
if (passport) {
|
|
269
|
-
txb.moveCall({
|
|
270
|
-
target:
|
|
271
|
-
arguments:[passport, Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, repository), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
254
|
+
this.txb.moveCall({
|
|
255
|
+
target:Protocol.Instance().MachineFn('repository_add_with_passport') as FnCallType,
|
|
256
|
+
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, repository), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
272
257
|
})
|
|
273
258
|
} else {
|
|
274
|
-
txb.moveCall({
|
|
275
|
-
target:
|
|
276
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, repository), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
259
|
+
this.txb.moveCall({
|
|
260
|
+
target:Protocol.Instance().MachineFn('repository_add') as FnCallType,
|
|
261
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, repository), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
277
262
|
})
|
|
278
263
|
}
|
|
279
264
|
}
|
|
@@ -286,97 +271,91 @@ export class Machine {
|
|
|
286
271
|
if (!IsValidArray(repositories, IsValidAddress)){
|
|
287
272
|
ERROR(Errors.IsValidArray, 'remove_repository')
|
|
288
273
|
}
|
|
289
|
-
|
|
290
|
-
let txb = this.protocol.CurrentSession();
|
|
274
|
+
|
|
291
275
|
if (passport) {
|
|
292
276
|
if (removeall) {
|
|
293
|
-
txb.moveCall({
|
|
294
|
-
target:
|
|
295
|
-
arguments:[passport, Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, this.object)],
|
|
277
|
+
this.txb.moveCall({
|
|
278
|
+
target:Protocol.Instance().MachineFn('repository_remove_all_with_passport') as FnCallType,
|
|
279
|
+
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.object)],
|
|
296
280
|
})
|
|
297
281
|
} else {
|
|
298
|
-
txb.moveCall({
|
|
299
|
-
target:
|
|
300
|
-
arguments:[passport, Protocol.TXB_OBJECT(txb, this.object), txb.pure(array_unique(repositories)
|
|
301
|
-
Protocol.TXB_OBJECT(txb, this.permission)],
|
|
282
|
+
this.txb.moveCall({
|
|
283
|
+
target:Protocol.Instance().MachineFn('repository_remove_with_passport') as FnCallType,
|
|
284
|
+
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('address', array_unique(repositories)),
|
|
285
|
+
Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
302
286
|
})
|
|
303
287
|
}
|
|
304
288
|
} else {
|
|
305
289
|
if (removeall) {
|
|
306
|
-
txb.moveCall({
|
|
307
|
-
target:
|
|
308
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
290
|
+
this.txb.moveCall({
|
|
291
|
+
target:Protocol.Instance().MachineFn('repository_remove_all') as FnCallType,
|
|
292
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
309
293
|
})
|
|
310
294
|
} else {
|
|
311
|
-
txb.moveCall({
|
|
312
|
-
target:
|
|
313
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(array_unique(repositories)
|
|
314
|
-
Protocol.TXB_OBJECT(txb, this.permission)],
|
|
295
|
+
this.txb.moveCall({
|
|
296
|
+
target:Protocol.Instance().MachineFn('repository_remove') as FnCallType,
|
|
297
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('address', array_unique(repositories)),
|
|
298
|
+
Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
315
299
|
})
|
|
316
300
|
}
|
|
317
301
|
}
|
|
318
302
|
}
|
|
319
303
|
|
|
320
304
|
clone(passport?:PassportObject) : MachineObject {
|
|
321
|
-
let txb = this.protocol.CurrentSession();
|
|
322
305
|
if (passport) {
|
|
323
|
-
return txb.moveCall({
|
|
324
|
-
target:
|
|
325
|
-
arguments:[passport, Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
306
|
+
return this.txb.moveCall({
|
|
307
|
+
target:Protocol.Instance().MachineFn('clone_with_passport') as FnCallType,
|
|
308
|
+
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
326
309
|
})
|
|
327
310
|
} else {
|
|
328
|
-
return txb.moveCall({
|
|
329
|
-
target:
|
|
330
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
311
|
+
return this.txb.moveCall({
|
|
312
|
+
target:Protocol.Instance().MachineFn('clone') as FnCallType,
|
|
313
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
331
314
|
})
|
|
332
315
|
}
|
|
333
316
|
}
|
|
334
317
|
|
|
335
|
-
set_endpoint(endpoint?:string|null, passport?:PassportObject) {
|
|
318
|
+
set_endpoint(endpoint?:string|null|undefined, passport?:PassportObject) {
|
|
336
319
|
if (endpoint && !IsValidEndpoint(endpoint)) {
|
|
337
320
|
ERROR(Errors.IsValidEndpoint)
|
|
338
321
|
}
|
|
339
322
|
|
|
340
|
-
let
|
|
341
|
-
let ep = endpoint? txb.pure(Bcs.getInstance().ser(ValueType.TYPE_OPTION_STRING, endpoint)) : OptionNone(txb);
|
|
342
|
-
|
|
323
|
+
let ep = this.txb.pure.option('string', endpoint ? endpoint : undefined) ;
|
|
343
324
|
if (passport) {
|
|
344
|
-
txb.moveCall({
|
|
345
|
-
target:
|
|
346
|
-
arguments:[passport, Protocol.TXB_OBJECT(txb, this.object), ep, Protocol.TXB_OBJECT(txb, this.permission)],
|
|
325
|
+
this.txb.moveCall({
|
|
326
|
+
target:Protocol.Instance().MachineFn('endpoint_set_with_passport') as FnCallType,
|
|
327
|
+
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), ep, Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
347
328
|
})
|
|
348
329
|
} else {
|
|
349
|
-
txb.moveCall({
|
|
350
|
-
target:
|
|
351
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object), ep, Protocol.TXB_OBJECT(txb, this.permission)],
|
|
330
|
+
this.txb.moveCall({
|
|
331
|
+
target:Protocol.Instance().MachineFn('endpoint_set') as FnCallType,
|
|
332
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), ep, Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
352
333
|
})
|
|
353
334
|
}
|
|
354
335
|
}
|
|
355
336
|
pause(bPaused:boolean, passport?:PassportObject) {
|
|
356
|
-
let txb = this.protocol.CurrentSession();
|
|
357
337
|
if (passport) {
|
|
358
|
-
txb.moveCall({
|
|
359
|
-
target:
|
|
360
|
-
arguments:[passport, Protocol.TXB_OBJECT(txb, this.object), txb.pure(bPaused), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
338
|
+
this.txb.moveCall({
|
|
339
|
+
target:Protocol.Instance().MachineFn('pause_with_passport') as FnCallType,
|
|
340
|
+
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.bool(bPaused), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
361
341
|
})
|
|
362
342
|
} else {
|
|
363
|
-
txb.moveCall({
|
|
364
|
-
target:
|
|
365
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(bPaused), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
343
|
+
this.txb.moveCall({
|
|
344
|
+
target:Protocol.Instance().MachineFn('pause') as FnCallType,
|
|
345
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.bool(bPaused), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
366
346
|
})
|
|
367
347
|
}
|
|
368
348
|
}
|
|
369
349
|
publish(passport?:PassportObject) {
|
|
370
|
-
let txb = this.protocol.CurrentSession();
|
|
371
350
|
if (passport) {
|
|
372
|
-
txb.moveCall({
|
|
373
|
-
target:
|
|
374
|
-
arguments:[passport, Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
351
|
+
this.txb.moveCall({
|
|
352
|
+
target:Protocol.Instance().MachineFn('publish_with_passport') as FnCallType,
|
|
353
|
+
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
375
354
|
})
|
|
376
355
|
} else {
|
|
377
|
-
txb.moveCall({
|
|
378
|
-
target:
|
|
379
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
356
|
+
this.txb.moveCall({
|
|
357
|
+
target:Protocol.Instance().MachineFn('publish') as FnCallType,
|
|
358
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
380
359
|
})
|
|
381
360
|
}
|
|
382
361
|
}
|
|
@@ -386,10 +365,9 @@ export class Machine {
|
|
|
386
365
|
ERROR(Errors.IsValidObjects, 'new_permission')
|
|
387
366
|
}
|
|
388
367
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
arguments: [Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, this.permission), Protocol.TXB_OBJECT(txb, new_permission)],
|
|
368
|
+
this.txb.moveCall({
|
|
369
|
+
target:Protocol.Instance().MachineFn('permission_set') as FnCallType,
|
|
370
|
+
arguments: [Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission), Protocol.TXB_OBJECT(this.txb, new_permission)],
|
|
393
371
|
typeArguments:[]
|
|
394
372
|
})
|
|
395
373
|
this.permission = new_permission;
|
|
@@ -400,25 +378,24 @@ export class Machine {
|
|
|
400
378
|
if (!IsValidName(node_name)) ERROR(Errors.IsValidName, 'add_forward');
|
|
401
379
|
if (!Machine.isValidForward(foward)) ERROR(Errors.InvalidParam, 'add_forward');
|
|
402
380
|
|
|
403
|
-
let txb = this.protocol.CurrentSession();
|
|
404
381
|
let n : any;
|
|
405
382
|
if (passport) {
|
|
406
|
-
n = txb.moveCall({
|
|
407
|
-
target:
|
|
408
|
-
arguments:[passport, Protocol.TXB_OBJECT(txb, this.object), txb.pure(node_name), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
383
|
+
n = this.txb.moveCall({
|
|
384
|
+
target:Protocol.Instance().MachineFn('node_fetch_with_passport') as FnCallType,
|
|
385
|
+
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(node_name), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
409
386
|
})
|
|
410
387
|
|
|
411
388
|
} else {
|
|
412
|
-
n = txb.moveCall({
|
|
413
|
-
target:
|
|
414
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(node_name), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
389
|
+
n = this.txb.moveCall({
|
|
390
|
+
target:Protocol.Instance().MachineFn('node_fetch') as FnCallType,
|
|
391
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(node_name), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
415
392
|
})
|
|
416
393
|
}
|
|
417
394
|
const f = this.forward(foward);
|
|
418
|
-
const t =
|
|
419
|
-
txb.moveCall({
|
|
420
|
-
target:
|
|
421
|
-
arguments:[n, txb.pure(node_prior), txb.pure(foward.name), t, f],
|
|
395
|
+
const t = this.txb.pure.option('u32', threshold);
|
|
396
|
+
this.txb.moveCall({
|
|
397
|
+
target:Protocol.Instance().MachineFn('forward_add') as FnCallType,
|
|
398
|
+
arguments:[n, this.txb.pure.string(node_prior), this.txb.pure.string(foward.name), t, f],
|
|
422
399
|
})
|
|
423
400
|
}
|
|
424
401
|
|
|
@@ -426,23 +403,22 @@ export class Machine {
|
|
|
426
403
|
if (!IsValidName_AllowEmpty(node_prior)) ERROR(Errors.IsValidName_AllowEmpty, 'add_forward');
|
|
427
404
|
if (!IsValidName(node_name)) ERROR(Errors.IsValidName, 'add_forward');
|
|
428
405
|
|
|
429
|
-
let txb = this.protocol.CurrentSession();
|
|
430
406
|
let n : any;
|
|
431
407
|
if (passport) {
|
|
432
|
-
n = txb.moveCall({
|
|
433
|
-
target:
|
|
434
|
-
arguments:[passport, Protocol.TXB_OBJECT(txb, this.object), txb.pure(node_name), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
408
|
+
n = this.txb.moveCall({
|
|
409
|
+
target:Protocol.Instance().MachineFn('node_fetch_with_passport') as FnCallType,
|
|
410
|
+
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(node_name), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
435
411
|
})
|
|
436
412
|
|
|
437
413
|
} else {
|
|
438
|
-
n = txb.moveCall({
|
|
439
|
-
target:
|
|
440
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(node_name), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
414
|
+
n = this.txb.moveCall({
|
|
415
|
+
target:Protocol.Instance().MachineFn('node_fetch') as FnCallType,
|
|
416
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(node_name), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
441
417
|
})
|
|
442
418
|
}
|
|
443
|
-
txb.moveCall({
|
|
444
|
-
target:
|
|
445
|
-
arguments:[n, txb.pure(node_prior), txb.pure(foward_name)],
|
|
419
|
+
this.txb.moveCall({
|
|
420
|
+
target:Protocol.Instance().MachineFn('forward_remove') as FnCallType,
|
|
421
|
+
arguments:[n, this.txb.pure.string(node_prior), this.txb.pure.string(foward_name)],
|
|
446
422
|
})
|
|
447
423
|
}
|
|
448
424
|
|