wowok_agent 1.3.47 → 1.3.48
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/dist/call/arbitration.d.ts +1 -0
- package/dist/call/arbitration.d.ts.map +1 -1
- package/dist/call/arbitration.js +137 -131
- package/dist/call/arbitration.js.map +1 -1
- package/dist/call/base.d.ts +4 -2
- package/dist/call/base.d.ts.map +1 -1
- package/dist/call/base.js +12 -4
- package/dist/call/base.js.map +1 -1
- package/dist/call/demand.d.ts +1 -0
- package/dist/call/demand.d.ts.map +1 -1
- package/dist/call/demand.js +86 -80
- package/dist/call/demand.js.map +1 -1
- package/dist/call/machine.d.ts +1 -0
- package/dist/call/machine.d.ts.map +1 -1
- package/dist/call/machine.js +156 -146
- package/dist/call/machine.js.map +1 -1
- package/dist/call/permission.d.ts +3 -2
- package/dist/call/permission.d.ts.map +1 -1
- package/dist/call/permission.js +90 -85
- package/dist/call/permission.js.map +1 -1
- package/dist/call/repository.d.ts +1 -0
- package/dist/call/repository.d.ts.map +1 -1
- package/dist/call/repository.js +102 -92
- package/dist/call/repository.js.map +1 -1
- package/dist/call/service.d.ts +1 -0
- package/dist/call/service.d.ts.map +1 -1
- package/dist/call/service.js +272 -262
- package/dist/call/service.js.map +1 -1
- package/dist/call/treasury.d.ts +1 -0
- package/dist/call/treasury.d.ts.map +1 -1
- package/dist/call/treasury.js +108 -97
- package/dist/call/treasury.js.map +1 -1
- package/package.json +1 -1
- package/src/call/arbitration.ts +140 -135
- package/src/call/base.ts +12 -6
- package/src/call/demand.ts +89 -81
- package/src/call/machine.ts +153 -141
- package/src/call/permission.ts +93 -85
- package/src/call/repository.ts +104 -92
- package/src/call/service.ts +272 -261
- package/src/call/treasury.ts +108 -96
- package/tsconfig.tsbuildinfo +1 -1
package/src/call/machine.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PassportObject, Errors, ERROR, Permission, PermissionIndex, TransactionBlock, TxbAddress,
|
|
2
2
|
PermissionIndexType, Machine, Machine_Forward, Machine_Node, Deliverable, ParentProgress, Progress, ProgressNext,
|
|
3
|
+
PermissionObject,
|
|
3
4
|
} from 'wowok';
|
|
4
5
|
import { CallBase, CallResult, GetObjectExisted, GetObjectMain, GetObjectParam, Namedbject, ObjectMain, TypeNamedObjectWithPermission } from "./base.js";
|
|
5
6
|
import { ObjectMachine } from '../query/objects.js';
|
|
@@ -38,19 +39,26 @@ export class CallMachine extends CallBase { //@ todo self-owned node operate
|
|
|
38
39
|
super();
|
|
39
40
|
this.data = data;
|
|
40
41
|
}
|
|
42
|
+
protected async prepare() {
|
|
43
|
+
if (!this.object_address) {
|
|
44
|
+
this.object_address = (await LocalMark.Instance().get_address(GetObjectExisted(this.data?.object)));
|
|
45
|
+
|
|
46
|
+
if (this.object_address) {
|
|
47
|
+
await this.update_content('Machine', this.object_address);
|
|
48
|
+
if (!this.content) ERROR(Errors.InvalidParam, 'CallMachine_Data.data.object:' + this.object_address);
|
|
49
|
+
this.permission_address = (this.content as ObjectMachine).permission;
|
|
50
|
+
} else {
|
|
51
|
+
const n = GetObjectMain(this.data?.object) as TypeNamedObjectWithPermission;
|
|
52
|
+
this.permission_address = (await LocalMark.Instance().get_address(GetObjectExisted(n?.permission)));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
41
57
|
async call(account?:string) : Promise<CallResult> {
|
|
42
58
|
var checkOwner = false; const guards : string[] = [];
|
|
43
59
|
const perms : PermissionIndexType[] = [];
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
await this.update_content('Machine', this.object_address);
|
|
47
|
-
if (!this.content) ERROR(Errors.InvalidParam, 'CallMachine_Data.data.object:' + this.object_address);
|
|
48
|
-
this.permission_address = (this.content as ObjectMachine).permission;
|
|
49
|
-
} else {
|
|
50
|
-
const n = GetObjectMain(this.data?.object) as TypeNamedObjectWithPermission;
|
|
51
|
-
this.permission_address = (await LocalMark.Instance().get_address(GetObjectExisted(n?.permission)));
|
|
52
|
-
}
|
|
53
|
-
|
|
60
|
+
|
|
61
|
+
await this.prepare();
|
|
54
62
|
if (this.permission_address) {
|
|
55
63
|
if (!this.data?.object) {
|
|
56
64
|
perms.push(PermissionIndex.machine)
|
|
@@ -120,158 +128,162 @@ export class CallMachine extends CallBase { //@ todo self-owned node operate
|
|
|
120
128
|
}
|
|
121
129
|
|
|
122
130
|
protected async operate(txb:TransactionBlock, passport?:PassportObject, account?:string) {
|
|
123
|
-
let obj : Machine | undefined ; let
|
|
131
|
+
let obj : Machine | undefined ; let perm: Permission | undefined;
|
|
132
|
+
let permission : PermissionObject | undefined;
|
|
133
|
+
|
|
124
134
|
if (this.object_address) {
|
|
125
135
|
obj = Machine.From(txb, this.permission_address!, this.object_address);
|
|
136
|
+
permission = this.permission_address;
|
|
126
137
|
} else {
|
|
127
138
|
const n = GetObjectMain(this.data?.object) as TypeNamedObjectWithPermission;
|
|
128
|
-
|
|
129
|
-
|
|
139
|
+
permission = await LocalMark.Instance().get_address(GetObjectExisted(n?.permission));
|
|
140
|
+
if (!permission) {
|
|
141
|
+
perm = Permission.New(txb, GetObjectParam(n?.permission)?.description ?? '');
|
|
142
|
+
permission = perm.get_object();
|
|
130
143
|
}
|
|
131
|
-
|
|
132
|
-
obj = Machine.New(txb, permission
|
|
144
|
+
|
|
145
|
+
obj = Machine.New(txb, permission, this.data?.description??'',
|
|
133
146
|
this.data?.endpoint, permission?undefined:passport);
|
|
134
147
|
}
|
|
135
148
|
|
|
136
|
-
if (obj)
|
|
137
|
-
|
|
138
|
-
const perm = permission ? permission.get_object() : this.permission_address;
|
|
149
|
+
if (!obj) ERROR(Errors.InvalidParam, 'CallMachine_Data.data.object');
|
|
150
|
+
if (!permission) ERROR(Errors.InvalidParam, 'CallMachine_Data.data.object.permission');
|
|
139
151
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
152
|
+
const pst = perm?undefined:passport;
|
|
153
|
+
var new_progress : Progress | undefined;
|
|
154
|
+
if (this.data?.progress_new !== undefined) {
|
|
155
|
+
const task = await LocalMark.Instance().get_address(this.data?.progress_new?.task_address);
|
|
156
|
+
new_progress = Progress?.New(txb, obj?.get_object(), permission, task, pst);
|
|
157
|
+
}
|
|
158
|
+
if (this.data?.progress_context_repository !== undefined) {
|
|
159
|
+
const p = this.data?.progress_context_repository.progress
|
|
160
|
+
? await LocalMark.Instance().get_address(this.data?.progress_context_repository.progress)
|
|
161
|
+
: new_progress?.get_object();
|
|
162
|
+
if (!p) ERROR(Errors.InvalidParam, 'CallMachine_Data.data.progress_context_repository.progress');
|
|
163
|
+
const rep = await LocalMark.Instance().get_address(this.data?.progress_context_repository.repository);
|
|
164
|
+
Progress.From(txb, obj?.get_object(), permission, p!).set_context_repository(rep, pst)
|
|
165
|
+
}
|
|
166
|
+
if (this.data?.progress_namedOperator !== undefined) {
|
|
167
|
+
const p = this.data?.progress_namedOperator.progress
|
|
168
|
+
? await LocalMark.Instance().get_address(this.data?.progress_namedOperator.progress)
|
|
169
|
+
: new_progress?.get_object();
|
|
170
|
+
if (!p) ERROR(Errors.InvalidParam, 'CallMachine_Data.data.progress_namedOperator.progress');
|
|
158
171
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
172
|
+
let pp = Progress.From(txb, obj?.get_object(), permission, p!);
|
|
173
|
+
this.data.progress_namedOperator.data.forEach(v => pp.set_namedOperator(v.name, v.operators, pst));
|
|
174
|
+
}
|
|
175
|
+
if (this.data?.progress_parent !== undefined) {
|
|
176
|
+
const p = this.data?.progress_parent.progress
|
|
177
|
+
? await LocalMark.Instance().get_address(this.data?.progress_parent.progress)
|
|
178
|
+
: new_progress?.get_object();
|
|
179
|
+
if (!p) ERROR(Errors.InvalidParam, 'CallMachine_Data.data.progress_parent.progress');
|
|
167
180
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
} else {
|
|
175
|
-
Progress.From(txb, obj?.get_object(), perm, p!).parent_none();
|
|
181
|
+
if (this.data.progress_parent.parent) {
|
|
182
|
+
const parent = await LocalMark.Instance().get_address(this.data.progress_parent.parent.parent_id);
|
|
183
|
+
if (parent) {
|
|
184
|
+
this.data.progress_parent.parent.parent_id = parent;
|
|
185
|
+
Progress.From(txb, obj?.get_object(), permission, p!).parent(this.data.progress_parent.parent);
|
|
176
186
|
}
|
|
187
|
+
} else {
|
|
188
|
+
Progress.From(txb, obj?.get_object(), permission, p!).parent_none();
|
|
177
189
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
190
|
+
}
|
|
191
|
+
if (this.data?.progress_hold !== undefined) {
|
|
192
|
+
const p = this.data?.progress_hold.progress
|
|
193
|
+
? await LocalMark.Instance().get_address(this.data?.progress_hold.progress)
|
|
194
|
+
: new_progress?.get_object();
|
|
195
|
+
if (!p) ERROR(Errors.InvalidParam, 'CallMachine_Data.data.progress_hold.progress');
|
|
183
196
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
197
|
+
if (this.data?.progress_hold.adminUnhold) {
|
|
198
|
+
Progress.From(txb, obj?.get_object(), permission, p!).unhold(this.data.progress_hold.operation, pst)
|
|
199
|
+
} else {
|
|
200
|
+
Progress.From(txb, obj?.get_object(), permission, p!).hold(this.data.progress_hold.operation, this.data.progress_hold.bHold)
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if (this.data?.progress_task !== undefined) {
|
|
204
|
+
const [p, task] = await LocalMark.Instance().get_many_address([this.data?.progress_task.progress, this.data?.progress_task.task_address]);
|
|
205
|
+
if (p && task) Progress.From(txb, obj?.get_object(), permission, p).bind_task(task, pst);
|
|
206
|
+
}
|
|
207
|
+
if (this.data?.progress_next !== undefined) {
|
|
208
|
+
const p = await LocalMark.Instance().get_address(this.data?.progress_next.progress);
|
|
209
|
+
if (!p) ERROR(Errors.InvalidParam, 'CallMachine_Data.data.progress_next.progress');
|
|
210
|
+
Progress.From(txb, obj?.get_object(), permission, p!).next(this.data.progress_next.operation, this.data.progress_next.deliverable, pst)
|
|
211
|
+
}
|
|
199
212
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
213
|
+
const addr = new_progress?.launch();
|
|
214
|
+
if (addr) {
|
|
215
|
+
await this.new_with_mark('Progress', txb, addr, this.data?.progress_new?.namedNew, account);
|
|
216
|
+
}
|
|
204
217
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
218
|
+
if (this.data?.description !== undefined && this.object_address) {
|
|
219
|
+
obj?.set_description(this.data.description, pst);
|
|
220
|
+
}
|
|
221
|
+
if (this.data?.endpoint !== undefined && this.object_address) {
|
|
222
|
+
obj?.set_endpoint(this.data.endpoint, pst)
|
|
223
|
+
}
|
|
211
224
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
obj?.remove_repository([], true, pst);
|
|
218
|
-
}
|
|
219
|
-
var reps = await LocalMark.Instance().get_many_address2(this.data.consensus_repository.repositories);
|
|
220
|
-
reps.forEach(v=>obj?.add_repository(v, pst)) ;
|
|
221
|
-
break;
|
|
222
|
-
case 'remove':
|
|
223
|
-
var reps = await LocalMark.Instance().get_many_address2(this.data.consensus_repository.repositories);
|
|
224
|
-
if (reps.length > 0) {
|
|
225
|
-
obj?.remove_repository(reps, false, pst);
|
|
226
|
-
}
|
|
227
|
-
break;
|
|
228
|
-
case 'removeall':
|
|
225
|
+
if (this.data?.consensus_repository !== undefined) {
|
|
226
|
+
switch (this.data.consensus_repository.op) {
|
|
227
|
+
case 'add':
|
|
228
|
+
case 'set':
|
|
229
|
+
if (this.data.consensus_repository.op === 'set') {
|
|
229
230
|
obj?.remove_repository([], true, pst);
|
|
230
|
-
break;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
if (this.data?.nodes !== undefined) {
|
|
234
|
-
switch (this.data?.nodes?.op) {
|
|
235
|
-
case 'add':
|
|
236
|
-
obj?.add_node(this.data.nodes.data, pst)
|
|
237
|
-
break;
|
|
238
|
-
case 'remove':
|
|
239
|
-
obj?.remove_node(this.data.nodes.names, this.data.nodes?.bTransferMyself, pst)
|
|
240
|
-
break;
|
|
241
|
-
case 'rename node':
|
|
242
|
-
this.data.nodes.data.forEach(v => obj?.rename_node(v.old, v.new, pst));
|
|
243
|
-
break;
|
|
244
|
-
case 'add from myself':
|
|
245
|
-
obj?.add_node2(this.data.nodes.addresses, pst);
|
|
246
|
-
break;
|
|
247
|
-
case 'add forward':
|
|
248
|
-
this.data.nodes.data.forEach(v => obj?.add_forward(v.prior_node_name, v.node_name, v.forward, v.threshold, v.remove_forward, pst))
|
|
249
|
-
break;
|
|
250
|
-
case 'remove forward':
|
|
251
|
-
this.data.nodes.data.forEach(v => obj?.remove_forward(v.prior_node_name, v.node_name, v.forward_name, pst))
|
|
252
|
-
break;
|
|
253
|
-
case 'remove pair':
|
|
254
|
-
this.data.nodes.pairs.forEach(v => obj?.remove_pair(v.prior_node_name, v.node_name, pst));
|
|
255
|
-
break;
|
|
256
231
|
}
|
|
232
|
+
var reps = await LocalMark.Instance().get_many_address2(this.data.consensus_repository.repositories);
|
|
233
|
+
reps.forEach(v=>obj?.add_repository(v, pst)) ;
|
|
234
|
+
break;
|
|
235
|
+
case 'remove':
|
|
236
|
+
var reps = await LocalMark.Instance().get_many_address2(this.data.consensus_repository.repositories);
|
|
237
|
+
if (reps.length > 0) {
|
|
238
|
+
obj?.remove_repository(reps, false, pst);
|
|
239
|
+
}
|
|
240
|
+
break;
|
|
241
|
+
case 'removeall':
|
|
242
|
+
obj?.remove_repository([], true, pst);
|
|
243
|
+
break;
|
|
257
244
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
245
|
+
}
|
|
246
|
+
if (this.data?.nodes !== undefined) {
|
|
247
|
+
switch (this.data?.nodes?.op) {
|
|
248
|
+
case 'add':
|
|
249
|
+
obj?.add_node(this.data.nodes.data, pst)
|
|
250
|
+
break;
|
|
251
|
+
case 'remove':
|
|
252
|
+
obj?.remove_node(this.data.nodes.names, this.data.nodes?.bTransferMyself, pst)
|
|
253
|
+
break;
|
|
254
|
+
case 'rename node':
|
|
255
|
+
this.data.nodes.data.forEach(v => obj?.rename_node(v.old, v.new, pst));
|
|
256
|
+
break;
|
|
257
|
+
case 'add from myself':
|
|
258
|
+
obj?.add_node2(this.data.nodes.addresses, pst);
|
|
259
|
+
break;
|
|
260
|
+
case 'add forward':
|
|
261
|
+
this.data.nodes.data.forEach(v => obj?.add_forward(v.prior_node_name, v.node_name, v.forward, v.threshold, v.remove_forward, pst))
|
|
262
|
+
break;
|
|
263
|
+
case 'remove forward':
|
|
264
|
+
this.data.nodes.data.forEach(v => obj?.remove_forward(v.prior_node_name, v.node_name, v.forward_name, pst))
|
|
265
|
+
break;
|
|
266
|
+
case 'remove pair':
|
|
267
|
+
this.data.nodes.pairs.forEach(v => obj?.remove_pair(v.prior_node_name, v.node_name, pst));
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
if (this.data?.bPublished ) {
|
|
272
|
+
obj?.publish(passport)
|
|
273
|
+
}
|
|
261
274
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
}
|
|
275
|
+
if (this.data?.bPaused !== undefined) {
|
|
276
|
+
obj?.pause(this.data.bPaused, pst)
|
|
277
|
+
}
|
|
278
|
+
if (this.data?.clone_new !== undefined && this.object_address) {
|
|
279
|
+
await this.new_with_mark('Machine', txb, obj?.clone(true, pst) as TxbAddress, (this.data?.clone_new as any)?.namedNew, account);
|
|
280
|
+
}
|
|
281
|
+
if (perm) {
|
|
282
|
+
const n = GetObjectMain(this.data?.object) as TypeNamedObjectWithPermission;
|
|
283
|
+
await this.new_with_mark('Permission', txb, perm.launch(), GetObjectParam(n?.permission), account);
|
|
284
|
+
}
|
|
285
|
+
if (!this.object_address) {
|
|
286
|
+
await this.new_with_mark('Machine', txb, obj.launch(), GetObjectMain(this.data?.object), account);
|
|
275
287
|
}
|
|
276
288
|
}
|
|
277
289
|
}
|
package/src/call/permission.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { LocalMark } from "../local/local.js";
|
|
2
2
|
import { AccountOrMark_Address, CallBase, CallResult, GetAccountOrMark_Address, GetManyAccountOrMark_Address,
|
|
3
|
-
GetObjectExisted, GetObjectMain, ObjectMain
|
|
3
|
+
GetObjectExisted, GetObjectMain, ObjectMain,
|
|
4
|
+
ObjectPermissionMain} from "./base.js";
|
|
4
5
|
import { PassportObject, Permission, BizPermission,
|
|
5
6
|
PermissionIndexType, TransactionBlock, Permission_Entity as Wowok_Permission_Entity,
|
|
6
|
-
Permission_Index as Wowok_Permission_Index, Permission_Index_Entity as Wowok_Permission_Index_Entity,
|
|
7
|
+
Permission_Index as Wowok_Permission_Index, Permission_Index_Entity as Wowok_Permission_Index_Entity,
|
|
8
|
+
ERROR,
|
|
9
|
+
Errors,
|
|
7
10
|
} from 'wowok';
|
|
8
11
|
|
|
9
12
|
|
|
@@ -29,7 +32,7 @@ export interface Permission_Index {
|
|
|
29
32
|
}
|
|
30
33
|
/// The execution priority is determined by the order in which the object attributes are arranged
|
|
31
34
|
export interface CallPermission_Data {
|
|
32
|
-
object?:
|
|
35
|
+
object?: ObjectPermissionMain;
|
|
33
36
|
description?: string;
|
|
34
37
|
biz_permission?: {op:'add'; data: BizPermission[]} | {op:'remove'; permissions: PermissionIndexType[]};
|
|
35
38
|
permission?: {op:'add entity'; entities:Permission_Entity[]} | {op:'add permission'; permissions:Permission_Index[]}
|
|
@@ -46,10 +49,15 @@ export class CallPermission extends CallBase {
|
|
|
46
49
|
this.data = data;
|
|
47
50
|
}
|
|
48
51
|
|
|
52
|
+
protected async prepare(): Promise<void> {
|
|
53
|
+
if (!this.object_address) {
|
|
54
|
+
this.object_address = await LocalMark.Instance().get_address(GetObjectExisted(this.data?.object));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
49
57
|
async call(account?:string) : Promise<CallResult> {
|
|
50
58
|
var checkOwner = false; var checkAdmin = false;
|
|
51
|
-
|
|
52
|
-
|
|
59
|
+
|
|
60
|
+
await this.prepare();
|
|
53
61
|
if (this.object_address) {
|
|
54
62
|
if (this.data?.builder !== undefined || this.data?.admin !== undefined) {
|
|
55
63
|
checkOwner = true;
|
|
@@ -73,92 +81,92 @@ export class CallPermission extends CallBase {
|
|
|
73
81
|
obj = Permission.From(txb, this.object_address)
|
|
74
82
|
}
|
|
75
83
|
|
|
76
|
-
if (obj)
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
84
|
+
if (!obj) ERROR(Errors.InvalidParam, 'CallPermission_Data.data.object');
|
|
85
|
+
|
|
86
|
+
if (this.data?.description !== undefined && this.data?.object) {
|
|
87
|
+
obj?.set_description(this.data.description)
|
|
88
|
+
}
|
|
89
|
+
if (this.data?.biz_permission !== undefined) { // High priority operate
|
|
90
|
+
switch(this.data.biz_permission.op) {
|
|
91
|
+
case 'add':
|
|
92
|
+
this.data.biz_permission.data.forEach(v => {
|
|
93
|
+
obj?.add_bizPermission(v.index, v.name);
|
|
94
|
+
})
|
|
95
|
+
break;
|
|
96
|
+
case 'remove':
|
|
97
|
+
this.data.biz_permission.permissions.forEach(v => {
|
|
98
|
+
obj?.remove_bizPermission(v);
|
|
99
|
+
})
|
|
100
|
+
break;
|
|
93
101
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
102
|
+
}
|
|
103
|
+
if (this.data?.permission !== undefined) {
|
|
104
|
+
switch (this.data.permission.op) {
|
|
105
|
+
case 'add entity':
|
|
106
|
+
var add_entity:Wowok_Permission_Entity[] = [];
|
|
107
|
+
for (let i = 0; i < this.data.permission.entities.length; ++i) {
|
|
108
|
+
const v = this.data.permission.entities[i];
|
|
109
|
+
const addr = await GetAccountOrMark_Address(v.entity);
|
|
110
|
+
if (addr) {
|
|
111
|
+
add_entity.push({address:addr, permissions:v.permissions});
|
|
104
112
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
113
|
+
}
|
|
114
|
+
obj?.add_entity(add_entity);
|
|
115
|
+
break;
|
|
116
|
+
case 'add permission':
|
|
117
|
+
var add_permission: Wowok_Permission_Index[] = [];
|
|
118
|
+
for (let i = 0; i < this.data.permission.permissions.length; ++i) {
|
|
119
|
+
const v = this.data.permission.permissions[i];
|
|
120
|
+
const e:Wowok_Permission_Index_Entity[] = [];
|
|
121
|
+
for (let j = 0; j < v.entities.length; ++j) {
|
|
122
|
+
const addr = await GetAccountOrMark_Address(v.entities[j].entity);
|
|
123
|
+
const guard = await LocalMark.Instance().get_address(v.entities[j].guard as string) ;
|
|
124
|
+
if (addr) {
|
|
125
|
+
e.push({address:addr, guard:guard})
|
|
118
126
|
}
|
|
119
|
-
add_permission.push({index:v.index, entities:e});
|
|
120
127
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
if (this.data?.admin !== undefined) {
|
|
139
|
-
switch(this.data.admin?.op) {
|
|
140
|
-
case 'add':
|
|
141
|
-
case 'set':
|
|
142
|
-
if (this.data.admin?.op === 'set') obj?.remove_admin([], true);
|
|
143
|
-
const add = await GetManyAccountOrMark_Address(this.data.admin.entities);
|
|
144
|
-
obj?.add_admin(add.filter((v): v is string => v!== undefined));
|
|
145
|
-
break;
|
|
146
|
-
case 'remove':
|
|
147
|
-
const remove = await GetManyAccountOrMark_Address(this.data.admin.entities);
|
|
148
|
-
obj?.remove_admin(remove.filter((v): v is string => typeof(v) === 'string'));
|
|
149
|
-
break;
|
|
150
|
-
case 'removeall':
|
|
151
|
-
obj?.remove_admin([], true);
|
|
152
|
-
break;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
if (this.data?.builder !== undefined ) {
|
|
156
|
-
const b = await GetAccountOrMark_Address(this.data.builder);
|
|
157
|
-
if (b) obj?.change_owner(b);
|
|
128
|
+
add_permission.push({index:v.index, entities:e});
|
|
129
|
+
}
|
|
130
|
+
obj?.add_entity3(add_permission);
|
|
131
|
+
break;
|
|
132
|
+
case 'remove entity':
|
|
133
|
+
const entities:string[] = (await GetManyAccountOrMark_Address(this.data.permission.entities)).filter((v): v is string => v!== undefined);
|
|
134
|
+
obj?.remove_entity(entities);
|
|
135
|
+
break;
|
|
136
|
+
case 'remove permission':
|
|
137
|
+
const addr = await GetAccountOrMark_Address(this.data.permission.entity);
|
|
138
|
+
if (addr) obj?.remove_index(addr, this.data.permission.index);
|
|
139
|
+
break;
|
|
140
|
+
case 'transfer permission':
|
|
141
|
+
const from = await GetAccountOrMark_Address(this.data.permission.from_entity);
|
|
142
|
+
const to = await GetAccountOrMark_Address(this.data.permission.to_entity);
|
|
143
|
+
if (from && to) obj?.transfer_permission(from, to);
|
|
144
|
+
break;
|
|
158
145
|
}
|
|
159
|
-
|
|
160
|
-
|
|
146
|
+
}
|
|
147
|
+
if (this.data?.admin !== undefined) {
|
|
148
|
+
switch(this.data.admin?.op) {
|
|
149
|
+
case 'add':
|
|
150
|
+
case 'set':
|
|
151
|
+
if (this.data.admin?.op === 'set') obj?.remove_admin([], true);
|
|
152
|
+
const add = await GetManyAccountOrMark_Address(this.data.admin.entities);
|
|
153
|
+
obj?.add_admin(add.filter((v): v is string => v!== undefined));
|
|
154
|
+
break;
|
|
155
|
+
case 'remove':
|
|
156
|
+
const remove = await GetManyAccountOrMark_Address(this.data.admin.entities);
|
|
157
|
+
obj?.remove_admin(remove.filter((v): v is string => typeof(v) === 'string'));
|
|
158
|
+
break;
|
|
159
|
+
case 'removeall':
|
|
160
|
+
obj?.remove_admin([], true);
|
|
161
|
+
break;
|
|
161
162
|
}
|
|
162
163
|
}
|
|
164
|
+
if (this.data?.builder !== undefined ) {
|
|
165
|
+
const b = await GetAccountOrMark_Address(this.data.builder);
|
|
166
|
+
if (b) obj?.change_owner(b);
|
|
167
|
+
}
|
|
168
|
+
if (!this.object_address) {
|
|
169
|
+
await this.new_with_mark('Permission', txb, obj.launch(), GetObjectMain(this.data?.object), account);
|
|
170
|
+
}
|
|
163
171
|
}
|
|
164
172
|
}
|