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