wowok_agent 1.2.45 → 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.
Files changed (70) hide show
  1. package/dist/call/arbitration.d.ts +13 -28
  2. package/dist/call/arbitration.d.ts.map +1 -1
  3. package/dist/call/arbitration.js +91 -84
  4. package/dist/call/arbitration.js.map +1 -1
  5. package/dist/call/base.d.ts +31 -2
  6. package/dist/call/base.d.ts.map +1 -1
  7. package/dist/call/base.js +41 -3
  8. package/dist/call/base.js.map +1 -1
  9. package/dist/call/call.d.ts +6 -0
  10. package/dist/call/call.d.ts.map +1 -1
  11. package/dist/call/call.js.map +1 -1
  12. package/dist/call/demand.d.ts +9 -22
  13. package/dist/call/demand.d.ts.map +1 -1
  14. package/dist/call/demand.js +70 -78
  15. package/dist/call/demand.js.map +1 -1
  16. package/dist/call/machine.d.ts +35 -44
  17. package/dist/call/machine.d.ts.map +1 -1
  18. package/dist/call/machine.js +105 -115
  19. package/dist/call/machine.js.map +1 -1
  20. package/dist/call/object_permission.d.ts.map +1 -1
  21. package/dist/call/object_permission.js.map +1 -1
  22. package/dist/call/permission.d.ts +30 -18
  23. package/dist/call/permission.d.ts.map +1 -1
  24. package/dist/call/permission.js +39 -38
  25. package/dist/call/permission.js.map +1 -1
  26. package/dist/call/personal.d.ts +6 -6
  27. package/dist/call/personal.d.ts.map +1 -1
  28. package/dist/call/personal.js +11 -13
  29. package/dist/call/personal.js.map +1 -1
  30. package/dist/call/repository.d.ts +4 -12
  31. package/dist/call/repository.d.ts.map +1 -1
  32. package/dist/call/repository.js +49 -37
  33. package/dist/call/repository.js.map +1 -1
  34. package/dist/call/service.d.ts +50 -70
  35. package/dist/call/service.d.ts.map +1 -1
  36. package/dist/call/service.js +187 -164
  37. package/dist/call/service.js.map +1 -1
  38. package/dist/call/treasury.d.ts +22 -26
  39. package/dist/call/treasury.d.ts.map +1 -1
  40. package/dist/call/treasury.js +74 -73
  41. package/dist/call/treasury.js.map +1 -1
  42. package/dist/common.d.ts +1 -0
  43. package/dist/common.d.ts.map +1 -1
  44. package/dist/common.js +6 -0
  45. package/dist/common.js.map +1 -1
  46. package/dist/local/local.d.ts +1 -1
  47. package/dist/local/local.d.ts.map +1 -1
  48. package/dist/local/local.js +4 -1
  49. package/dist/local/local.js.map +1 -1
  50. package/dist/query/objects.d.ts +6 -2
  51. package/dist/query/objects.d.ts.map +1 -1
  52. package/dist/query/objects.js +8 -1
  53. package/dist/query/objects.js.map +1 -1
  54. package/package.json +4 -2
  55. package/src/call/arbitration.ts +117 -105
  56. package/src/call/base.ts +78 -10
  57. package/src/call/call.ts +6 -0
  58. package/src/call/demand.ts +77 -86
  59. package/src/call/machine.ts +119 -132
  60. package/src/call/object_permission.ts +1 -1
  61. package/src/call/permission.ts +68 -45
  62. package/src/call/personal.ts +18 -20
  63. package/src/call/repository.ts +54 -47
  64. package/src/call/service.ts +236 -197
  65. package/src/call/treasury.ts +96 -86
  66. package/src/common.ts +7 -1
  67. package/src/local/account.ts +1 -1
  68. package/src/local/local.ts +6 -2
  69. package/src/query/objects.ts +17 -4
  70. package/tsconfig.tsbuildinfo +1 -1
@@ -1,26 +1,30 @@
1
- import { TransactionBlock, IsValidArgType, IsValidCoinType, Resource, ResourceObject } from 'wowok';
2
- import { PassportObject, IsValidAddress, Errors, ERROR, Permission, PermissionIndex,
1
+ import { TransactionBlock, IsValidArgType, Service, PassportObject, Errors, ERROR, Permission, PermissionIndex,
3
2
  PermissionIndexType, Demand, } from 'wowok';
4
- import { query_objects, ObjectDemand } from '../query/objects.js';
5
- import { CallBase, CallResult, Namedbject } from "./base.js";
3
+ import { ObjectDemand, query_objects } from '../query/objects.js';
4
+ import { CallBase, CallResult, GetObjectExisted, GetObjectMain, GetObjectParam, ObjectTypedMain, TypeNamedObjectWithPermission } from "./base.js";
6
5
  import { Account } from '../local/account.js';
7
6
  import { LocalMark } from '../local/local.js';
8
7
 
9
8
  /// The execution priority is determined by the order in which the object attributes are arranged
10
9
  export interface CallDemand_Data {
11
- type_parameter: string;
12
- object?: {address:string} | {namedNew?: Namedbject}; // undefined or {named_new...} for creating a new object
13
- permission?: {address:string} | {namedNew?: Namedbject, description?:string};
10
+ object: ObjectTypedMain;
11
+ // service to present.
12
+ // If Demand.guard.service_id_in_guard is set, the service address must be provided as the service_id_in_guard identifier while Guard verification is performed.
13
+ // Otherwise, the service address is used to present the service to the Demand.
14
+ present?: {service?: string; recommend_words:string;};
15
+
14
16
  description?: string;
15
17
  time_expire?: {op: 'duration'; minutes:number} | {op:'time'; time:number};
16
18
  bounty?: {op:'add'; object:{address:string}|{balance:string|number}} | {op:'reward'; service:string} | {op:'refund'} ;
17
- present?: {service: string | number; recommend_words:string; service_pay_type:string, guard?:string}; // guard is the present guard of Demand
19
+ // If service_id_in_guard is set, the service address must be provided as the service_id_in_guard identifier while Guard verification is performed.
18
20
  guard?: {address:string; service_id_in_guard?:number};
19
21
  }
20
22
 
21
23
  export class CallDemand extends CallBase {
22
24
  data: CallDemand_Data;
23
- content: ObjectDemand | undefined = undefined;
25
+ object_address: string | undefined = undefined;
26
+ permission_address: string | undefined = undefined;
27
+ type_parameter: string | undefined = undefined;
24
28
 
25
29
  constructor(data: CallDemand_Data) {
26
30
  super();
@@ -29,105 +33,102 @@ export class CallDemand extends CallBase {
29
33
  async call(account?:string) : Promise<CallResult> {
30
34
  var checkOwner = false; const guards : string[] = [];
31
35
  const perms : PermissionIndexType[] = [];
32
- var [permission_address, object_address] =
33
- await LocalMark.Instance().get_many_address(
34
- [(this.data?.permission as any)?.address,
35
- (this.data?.object as any)?.address]);
36
-
37
- if (object_address) {
38
- if (!this.data.type_parameter || !permission_address) {
39
- await this.update_content(object_address, 'Demand');
40
- if (this.content) {
41
- permission_address = (this.content as ObjectDemand).permission;
42
- this.data.type_parameter = this.content.type_raw!;
43
- }
44
- }
36
+ this.object_address = (await LocalMark.Instance().get_address(GetObjectExisted(this.data.object)));
37
+ if (this.object_address) {
38
+ await this.update_content('Demand', this.object_address);
39
+ if (!this.content) ERROR(Errors.InvalidParam, 'CallDemand_Data.data.object:' + this.object_address);
40
+ this.permission_address = (this.content as ObjectDemand).permission;
41
+ this.type_parameter = Demand.parseObjectType(this.content.type_raw);
45
42
  } else {
46
- if (!this.data?.type_parameter || !IsValidArgType(this.data.type_parameter)) {
47
- ERROR(Errors.IsValidArgType, 'CallDemand_Data.data.type_parameter')
48
- }
49
- }
43
+ const n = GetObjectMain(this.data.object) as TypeNamedObjectWithPermission;
44
+ if (!n?.type_parameter || !IsValidArgType(n.type_parameter)) {
45
+ ERROR(Errors.IsValidArgType, 'CallDemand_Data.data.object.type_parameter');
46
+ }
47
+ this.permission_address = (await LocalMark.Instance().get_address(GetObjectExisted(n?.permission)));
48
+ this.type_parameter = n.type_parameter;
49
+ }
50
50
 
51
- if (permission_address) {
51
+ if (this.permission_address) {
52
52
  if (!this.data?.object) {
53
53
  perms.push(PermissionIndex.demand)
54
54
  }
55
- if (this.data?.description !== undefined && object_address) {
55
+ if (this.data?.description !== undefined && this.object_address) {
56
56
  perms.push(PermissionIndex.demand_description)
57
57
  }
58
- if (this.data?.time_expire !== undefined && object_address) {
58
+ if (this.data?.time_expire !== undefined && this.object_address) {
59
59
  perms.push(PermissionIndex.demand_expand_time)
60
60
  }
61
- if (this.data?.guard !== undefined) {
62
- perms.push(PermissionIndex.demand_guard)
63
- }
64
61
  if (this.data?.bounty?.op === 'reward') {
65
62
  perms.push(PermissionIndex.demand_yes)
66
63
  }
67
64
  if (this.data?.bounty?.op === 'refund') {
68
65
  perms.push(PermissionIndex.demand_refund)
69
66
  }
70
- if (this.data?.present?.guard !== undefined) {
71
- if (this.data.present.guard) {
72
- const guard = await LocalMark.Instance().get_address(this.data.present.guard)
67
+ if (this.data?.guard !== undefined) {
68
+ perms.push(PermissionIndex.demand_guard)
69
+ }
70
+ if (this.data?.present !== undefined) {
71
+ if (this.object_address) {
72
+ if ((this.content as ObjectDemand)?.guard?.object) {
73
+ guards.push((this.content as ObjectDemand).guard?.object!);
74
+ }
75
+ } /*else {
76
+ const guard = await LocalMark.Instance().get_address(this.data?.guard?.address);
73
77
  if (guard) {
74
78
  guards.push(guard)
75
- }
76
- } else {
77
- if (!object_address) { // new
78
- const guard = await LocalMark.Instance().get_address(this.data?.guard?.address);
79
- if (guard) {
80
- guards.push(guard)
81
- }
82
- } else {
83
- await this.update_content(object_address, 'Demand');
84
-
85
- if ((this.content as ObjectDemand)?.guard?.object) {
86
- guards.push((this.content as ObjectDemand).guard?.object!)
87
- }
88
79
  }
89
- }
80
+ }*/
90
81
  }
91
- return await this.check_permission_and_call(permission_address, perms, guards, checkOwner, undefined, account)
82
+ return await this.check_permission_and_call(this.permission_address, perms, guards, checkOwner, undefined, account)
92
83
  }
93
84
  return await this.exec(account);
94
85
  }
95
86
  protected async operate(txb:TransactionBlock, passport?:PassportObject, account?:string) {
96
87
  let obj : Demand | undefined ; let permission: any;
97
- var [permission_address, object_address] = this?.content ?
98
- [(this.content as ObjectDemand).permission, this.content.object] :
99
- await LocalMark.Instance().get_many_address(
100
- [(this.data?.permission as any)?.address,
101
- (this.data?.object as any)?.address]);
102
88
 
103
- if (!object_address) {
104
- if (!permission_address) {
105
- const d = (this.data?.permission as any)?.description ?? '';
106
- permission = Permission.New(txb, d);
89
+ if (this.object_address) {
90
+ obj = Demand.From(txb, this.type_parameter!, this.permission_address!, this.object_address)
91
+ } else {
92
+ const n = GetObjectMain(this.data.object) as TypeNamedObjectWithPermission;
93
+ if (!this.permission_address) {
94
+ permission = Permission.New(txb, GetObjectParam(n?.permission)?.description ?? '');
107
95
  }
108
96
 
109
97
  if (this.data.time_expire !== undefined) {
110
- obj = Demand.New(txb, this.data.type_parameter!, this.data.time_expire?.op === 'duration' ? true : false,
98
+ obj = Demand.New(txb, this.type_parameter!, this.data.time_expire?.op === 'duration' ? true : false,
111
99
  this.data.time_expire?.op === 'duration' ? this.data.time_expire.minutes : this.data.time_expire?.time,
112
- permission ? permission.get_object(): permission_address, this.data?.description??'', permission?undefined:passport)
113
- } else {
114
- obj = Demand.New(txb, this.data.type_parameter!, true, 30*24*60, // 30days default
115
- permission ? permission.get_object(): permission_address, this.data?.description??'', permission?undefined:passport)
116
- }
117
- } else {
118
- if (this.data.type_parameter && permission_address) {
119
- obj = Demand.From(txb, this.data.type_parameter, permission_address, object_address)
100
+ permission ? permission.get_object(): this.permission_address, this.data?.description??'', permission?undefined:passport)
120
101
  } else {
121
- ERROR(Errors.InvalidParam, 'CallDemand_Data.data.type_parameter or permission')
102
+ obj = Demand.New(txb, this.type_parameter!, true, 30*24*60, // 30days default
103
+ permission ? permission.get_object(): this.permission_address, this.data?.description??'', permission?undefined:passport)
122
104
  }
123
105
  }
124
106
 
125
107
  if (obj) {
126
108
  const pst = permission?undefined:passport;
127
- if (this.data?.description !== undefined && object_address) {
109
+ if (this.data?.present !== undefined) {
110
+ if ((this.content as ObjectDemand)?.guard?.service_id_in_guard !== undefined && (this.content as ObjectDemand)?.guard?.service_id_in_guard !== null) {
111
+ obj?.present((this.content as ObjectDemand)!.guard!.service_id_in_guard!, undefined, this.data.present.recommend_words, pst);
112
+ } else {
113
+ const service_address = await LocalMark.Instance().get_address(this.data.present.service);
114
+ if (!service_address) ERROR(Errors.InvalidParam, 'CallDemand_Data.data.present.service');
115
+ const r = await query_objects({objects:[service_address]});
116
+ if (r?.objects?.length !== 1 || r?.objects[0]?.type !== 'Service') {
117
+ ERROR(Errors.InvalidParam, 'CallDemand_Data.data.present.service: ' + service_address);
118
+ }
119
+ const service_type = Service.parseOrderObjectType(r.objects[0].type_raw);
120
+ if (!service_type) {
121
+ ERROR(Errors.InvalidParam, 'CallDemand_Data.data.present.service: ' + service_address);
122
+ }
123
+
124
+ obj?.present(service_address, service_type, this.data.present.recommend_words, pst);
125
+ }
126
+ }
127
+
128
+ if (this.data?.description !== undefined && this.object_address) {
128
129
  obj?.set_description(this.data.description, pst);
129
130
  }
130
- if (this.data?.time_expire !== undefined && object_address) {
131
+ if (this.data?.time_expire !== undefined && this.object_address) {
131
132
  obj?.expand_time(this.data.time_expire.op === 'duration' ? true : false,
132
133
  this.data.time_expire.op === 'duration' ? this.data.time_expire.minutes : this.data.time_expire.time, pst)
133
134
  }
@@ -135,12 +136,9 @@ export class CallDemand extends CallBase {
135
136
  if (this.data.bounty.op === 'add') {
136
137
  const bounty = await LocalMark.Instance().get_address((this.data.bounty.object as any)?.address)
137
138
  if (bounty) {
138
- obj.deposit((this.data.bounty.object as any)?.address)
139
+ obj.deposit(bounty)
139
140
  } else if ((this.data.bounty.object as any)?.balance !== undefined){
140
- if (!IsValidCoinType(this.data.type_parameter)) {
141
- ERROR(Errors.IsValidCoinType, 'CallDemand_Data.data.type_parameter')
142
- }
143
- const r = await Account.Instance().get_coin_object(txb, (this.data.bounty.object as any)?.balance, account, this.data.type_parameter);
141
+ const r = await Account.Instance().get_coin_object(txb, (this.data.bounty.object as any)?.balance, account, this.type_parameter);
144
142
  if (r) obj.deposit(r)
145
143
  }
146
144
  } else if (this.data.bounty.op === 'reward') {
@@ -151,14 +149,6 @@ export class CallDemand extends CallBase {
151
149
  obj?.refund(pst);
152
150
  }
153
151
  }
154
- if (this.data?.present !== undefined) {
155
- //@ demand guard and its pst, if set
156
- const service = typeof(this.data.present.service) === 'string' ? (await LocalMark.Instance().get_address(this.data.present.service)): this.data.present.service;
157
- if (service === undefined) {
158
- ERROR(Errors.InvalidParam, 'CallDemand_Data.data.present.service')
159
- }
160
- obj?.present(typeof(this.data.present.service) === 'string' ? service : this.data.present.service, this.data.present.service_pay_type, this.data.present.recommend_words, pst);
161
- }
162
152
 
163
153
  if (this.data?.guard !== undefined) {
164
154
  const guard = await LocalMark.Instance().get_address(this.data?.guard.address);
@@ -168,10 +158,11 @@ export class CallDemand extends CallBase {
168
158
  obj?.set_guard(guard, this.data.guard?.service_id_in_guard ?? undefined, pst);
169
159
  }
170
160
  if (permission) {
171
- await this.new_with_mark('Permission', txb, permission.launch(), (this.data?.permission as any)?.namedNew, account);
161
+ const n = GetObjectMain(this.data.object) as TypeNamedObjectWithPermission;
162
+ await this.new_with_mark('Permission', txb, permission.launch(), GetObjectParam(n?.permission), account);
172
163
  }
173
164
  if (!this.data.object) {
174
- await this.new_with_mark('Demand', txb, obj.launch(), (this.data?.object as any)?.namedNew, account);
165
+ await this.new_with_mark('Demand', txb, obj.launch(), GetObjectMain(this.data?.object), account);
175
166
  }
176
167
  }
177
168
  }
@@ -1,16 +1,22 @@
1
- import { PassportObject, IsValidAddress, Errors, ERROR, Permission, PermissionIndex, TransactionBlock, TxbAddress,
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?: {address:string} | {namedNew?: Namedbject}; // undefined or {named_new...} for creating a new object
13
- permission?: {address:string} | {namedNew?: Namedbject, description?:string};
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
- var [permission_address, object_address] =
43
- await LocalMark.Instance().get_many_address(
44
- [(this.data?.permission as any)?.address,
45
- (this.data?.object as any)?.address]);
46
-
47
- if (object_address) {
48
- if (!permission_address) {
49
- await this.update_content(object_address, 'Machine');
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.data?.progress_next?.guard) {
100
- const guard = await LocalMark.Instance().get_address(this.data?.progress_next?.guard);
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
- var [permission_address, object_address] = this?.content ?
125
- [(this.content as ObjectMachine).permission, this.content.object] :
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
- if (permission_address) {
138
- obj = Machine.From(txb, permission_address, object_address)
139
- } else {
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.task_address);
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
- await this.new_with_mark('Permission', txb, permission.launch(), (this.data?.permission as any)?.namedNew, account);
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 as any)?.namedNew, account);
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, IsValidAddress, Errors, ERROR, Demand, Machine, Service, Treasury, Arbitration, Repository} from 'wowok';
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