wowok_agent 0.0.1 → 0.1.3

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.
@@ -2,10 +2,12 @@ import { TransactionBlock, CallResponse} from 'wowok';
2
2
  import { PassportObject, IsValidAddress, Errors, ERROR, Permission, PermissionIndex, WitnessFill,
3
3
  PermissionIndexType, Machine, Machine_Forward, Machine_Node, Deliverable, ParentProgress, Progress, ProgressNext,
4
4
  } from 'wowok';
5
- import { CallBase } from "./call";
5
+ import { CallBase, CallResult } from "./base";
6
6
  import { Account } from '../account';
7
7
 
8
- export class CallMachine extends CallBase { //@ todo self-owned node operate
8
+ export interface CallMachine_Data {
9
+ object?: string; // undefined for creating a new object
10
+ permission?: string;
9
11
  permission_new?: string;
10
12
  bPaused?: boolean;
11
13
  bPublished?: boolean;
@@ -25,183 +27,189 @@ export class CallMachine extends CallBase { //@ todo self-owned node operate
25
27
  progress_namedOperator?: {progress:string; data:{name:string, operator:string[]}[]};
26
28
  progress_hold?: {progress:string; data:ProgressNext; bHold:boolean; adminUnhold?:boolean};
27
29
  progress_next?: {progress:string; data:ProgressNext; deliverable:Deliverable; guard?:string | 'fetch'};
28
- constructor(object: string | 'new' = 'new') { super(object) }
29
- async call(account?:string) : Promise<WitnessFill[] | CallResponse | undefined> {
30
+ }
31
+ export class CallMachine extends CallBase { //@ todo self-owned node operate
32
+ data: CallMachine_Data
33
+ constructor(data:CallMachine_Data) {
34
+ super();
35
+ this.data = data;
36
+ }
37
+ async call(account?:string) : Promise<CallResult> {
30
38
  var checkOwner = false; const guards : string[] = [];
31
39
  const perms : PermissionIndexType[] = [];
32
40
 
33
- if (this?.permission && IsValidAddress(this.permission)) {
34
- if (this?.object === 'new') {
41
+ if (this.data?.permission && IsValidAddress(this.data.permission)) {
42
+ if (!this.data?.object) {
35
43
  perms.push(PermissionIndex.machine)
36
44
  }
37
- if (this?.permission_new !== undefined) {
45
+ if (this.data?.permission_new !== undefined) {
38
46
  checkOwner = true;
39
47
  }
40
- if (this?.description !== undefined && this.object !== 'new') {
48
+ if (this.data?.description !== undefined && this.data.object) {
41
49
  perms.push(PermissionIndex.machine_description)
42
50
  }
43
- if (this?.bPaused !== undefined) {
51
+ if (this.data?.bPaused !== undefined) {
44
52
  perms.push(PermissionIndex.machine_pause)
45
53
  }
46
- if (this?.bPublished) { // publish is an irreversible one-time operation
54
+ if (this.data?.bPublished) { // publish is an irreversible one-time operation
47
55
  perms.push(PermissionIndex.machine_publish)
48
56
  }
49
- if (this?.endpoint !== undefined && this.object !== 'new') {
57
+ if (this.data?.endpoint !== undefined && this.data.object) {
50
58
  perms.push(PermissionIndex.machine_endpoint)
51
59
  }
52
- if (this?.consensus_repository !== undefined) {
60
+ if (this.data?.consensus_repository !== undefined) {
53
61
  perms.push(PermissionIndex.machine_repository)
54
62
  }
55
- if (this?.clone_new !== undefined) {
63
+ if (this.data?.clone_new !== undefined) {
56
64
  perms.push(PermissionIndex.machine_clone)
57
65
  }
58
- if (this?.nodes !== undefined) {
66
+ if (this.data?.nodes !== undefined) {
59
67
  perms.push(PermissionIndex.machine_node)
60
68
  }
61
- if (this?.progress_new !== undefined) {
69
+ if (this.data?.progress_new !== undefined) {
62
70
  perms.push(PermissionIndex.progress)
63
71
  }
64
- if (this?.progress_context_repository !== undefined) {
72
+ if (this.data?.progress_context_repository !== undefined) {
65
73
  perms.push(PermissionIndex.progress_context_repository)
66
74
  }
67
- if (this?.progress_namedOperator !== undefined) {
75
+ if (this.data?.progress_namedOperator !== undefined) {
68
76
  perms.push(PermissionIndex.progress_namedOperator)
69
77
  }
70
- if (this?.progress_parent !== undefined) {
78
+ if (this.data?.progress_parent !== undefined) {
71
79
  perms.push(PermissionIndex.progress_parent)
72
80
  }
73
- if (this?.progress_task !== undefined) {
81
+ if (this.data?.progress_task !== undefined) {
74
82
  perms.push(PermissionIndex.progress_bind_task)
75
83
  }
76
- if (this?.progress_hold !== undefined) {
77
- if (this.progress_hold.adminUnhold) {
84
+ if (this.data?.progress_hold !== undefined) {
85
+ if (this.data.progress_hold.adminUnhold) {
78
86
  perms.push(PermissionIndex.progress_unhold)
79
87
  }
80
88
  }
81
- if (this?.progress_next?.guard !== undefined) {
82
- if (IsValidAddress(this?.progress_next?.guard)) {
83
- guards.push(this?.progress_next?.guard)
84
- } else if (this?.object && IsValidAddress(this.object)) { // fetch guard
85
- const guard = await Progress.QueryForwardGuard(this?.progress_next.progress, this.object,
89
+ if (this.data?.progress_next?.guard !== undefined) {
90
+ if (IsValidAddress(this.data?.progress_next?.guard)) {
91
+ guards.push(this.data?.progress_next?.guard)
92
+ } else if (this.data?.object && IsValidAddress(this.data.object)) { // fetch guard
93
+ const guard = await Progress.QueryForwardGuard(this.data?.progress_next.progress, this.data.object,
86
94
  Account.Instance().get_address() ?? '0xe386bb9e01b3528b75f3751ad8a1e418b207ad979fea364087deef5250a73d3f',
87
- this.progress_next.data.next_node_name, this.progress_next.data.forward);
95
+ this.data.progress_next.data.next_node_name, this.data.progress_next.data.forward);
88
96
  if (guard) {
89
97
  guards.push(guard)
90
98
  }
91
99
  }
92
100
  }
93
101
 
94
- return await this.check_permission_and_call(this.permission, perms, guards, checkOwner, undefined, account)
102
+ return await this.check_permission_and_call(this.data.permission, perms, guards, checkOwner, undefined, account)
95
103
  }
96
104
  return this.exec(account);
97
105
  }
98
106
 
99
107
  protected async operate(txb:TransactionBlock, passport?:PassportObject) {
100
108
  let obj : Machine | undefined ; let permission: any;
101
- if (this.object === 'new') {
102
- if (!this?.permission || !IsValidAddress(this?.permission)) {
109
+ if (!this.data.object) {
110
+ if (!this.data?.permission || !IsValidAddress(this.data?.permission)) {
103
111
  permission = Permission.New(txb, '');
104
112
  }
105
- obj = Machine.New(txb, permission ?? this?.permission, this?.description??'', this?.endpoint ?? '', permission?undefined:passport);
113
+ obj = Machine.New(txb, permission ?? this.data?.permission, this.data?.description??'', this.data?.endpoint ?? '', permission?undefined:passport);
106
114
  } else {
107
- if (IsValidAddress(this.object) && this.permission && IsValidAddress(this?.permission)) {
108
- obj = Machine.From(txb, this.permission, this.object)
115
+ if (IsValidAddress(this.data.object) && this.data.permission && IsValidAddress(this.data?.permission)) {
116
+ obj = Machine.From(txb, this.data.permission, this.data.object)
109
117
  }
110
118
  }
111
119
 
112
120
  if (obj) {
113
- if (this?.description !== undefined && this.object !== 'new') {
114
- obj?.set_description(this.description, passport);
121
+ if (this.data?.description !== undefined && this.data.object) {
122
+ obj?.set_description(this.data.description, passport);
115
123
  }
116
- if (this?.endpoint !== undefined && this.object !== 'new') {
117
- obj?.set_endpoint(this.endpoint, passport)
124
+ if (this.data?.endpoint !== undefined && this.data.object) {
125
+ obj?.set_endpoint(this.data.endpoint, passport)
118
126
  }
119
- if (this?.bPaused !== undefined) {
120
- obj?.pause(this.bPaused, passport)
127
+ if (this.data?.bPaused !== undefined) {
128
+ obj?.pause(this.data.bPaused, passport)
121
129
  }
122
- if (this?.bPublished ) {
130
+ if (this.data?.bPublished ) {
123
131
  obj?.publish(passport)
124
132
  }
125
- if (this?.clone_new) {
133
+ if (this.data?.clone_new) {
126
134
  obj?.clone(true, passport)
127
135
  }
128
- if (this?.consensus_repository !== undefined) {
129
- switch (this.consensus_repository.op) {
136
+ if (this.data?.consensus_repository !== undefined) {
137
+ switch (this.data.consensus_repository.op) {
130
138
  case 'add':
131
- this.consensus_repository.repositories.forEach(v=>obj?.add_repository(v, passport)) ;
139
+ this.data.consensus_repository.repositories.forEach(v=>obj?.add_repository(v, passport)) ;
132
140
  break;
133
141
  case 'remove':
134
- obj?.remove_repository(this.consensus_repository.repositories, false, passport);
142
+ obj?.remove_repository(this.data.consensus_repository.repositories, false, passport);
135
143
  break;
136
144
  case 'removeall':
137
145
  obj?.remove_repository([], true, passport);
138
146
  break;
139
147
  case 'set':
140
148
  obj?.remove_repository([], true, passport);
141
- this.consensus_repository.repositories.forEach(v=>obj?.add_repository(v, passport)) ;
149
+ this.data.consensus_repository.repositories.forEach(v=>obj?.add_repository(v, passport)) ;
142
150
  break;
143
151
  }
144
152
  }
145
- if (this?.nodes !== undefined) {
146
- switch (this?.nodes?.op) {
153
+ if (this.data?.nodes !== undefined) {
154
+ switch (this.data?.nodes?.op) {
147
155
  case 'add':
148
- obj?.add_node(this.nodes.data, passport)
156
+ obj?.add_node(this.data.nodes.data, passport)
149
157
  break;
150
158
  case 'remove':
151
- obj?.remove_node(this.nodes.names, this.nodes?.bTransferMyself, passport)
159
+ obj?.remove_node(this.data.nodes.names, this.data.nodes?.bTransferMyself, passport)
152
160
  break;
153
161
  case 'rename node':
154
- this.nodes.data.forEach(v => obj?.rename_node(v.old, v.new, passport));
162
+ this.data.nodes.data.forEach(v => obj?.rename_node(v.old, v.new, passport));
155
163
  break;
156
164
  case 'add from myself':
157
- obj?.add_node2(this.nodes.addresses, passport);
165
+ obj?.add_node2(this.data.nodes.addresses, passport);
158
166
  break;
159
167
  case 'add forward':
160
- this.nodes.data.forEach(v => obj?.add_forward(v.prior_node_name, v.node_name, v.forward, v.threshold, v.old_need_remove, passport))
168
+ this.data.nodes.data.forEach(v => obj?.add_forward(v.prior_node_name, v.node_name, v.forward, v.threshold, v.old_need_remove, passport))
161
169
  break;
162
170
  case 'remove forward':
163
- this.nodes.data.forEach(v => obj?.remove_forward(v.prior_node_name, v.node_name, v.forward_name, passport))
171
+ this.data.nodes.data.forEach(v => obj?.remove_forward(v.prior_node_name, v.node_name, v.forward_name, passport))
164
172
  break;
165
173
  }
166
174
  }
167
- if (this?.progress_new !== undefined) {
168
- Progress?.New(txb, this?.object, permission??this?.permission, this?.progress_new.task_address, passport).launch();
175
+ if (this.data?.progress_new !== undefined) {
176
+ Progress?.New(txb, obj?.get_object(), permission??this.data?.permission, this.data?.progress_new.task_address, passport).launch();
169
177
  }
170
- if (this?.progress_context_repository !== undefined) {
171
- Progress.From(txb, this?.object, permission??this?.permission, this?.progress_context_repository.progress)
172
- .set_context_repository(this?.progress_context_repository.repository, passport)
178
+ if (this.data?.progress_context_repository !== undefined) {
179
+ Progress.From(txb, obj?.get_object(), permission??this.data?.permission, this.data?.progress_context_repository.progress)
180
+ .set_context_repository(this.data?.progress_context_repository.repository, passport)
173
181
  }
174
- if (this?.progress_namedOperator !== undefined) {
175
- const p = Progress.From(txb, this?.object, permission??this?.permission, this?.progress_namedOperator.progress);
176
- this.progress_namedOperator.data.forEach(v => p.set_namedOperator(v.name, v.operator, passport));
182
+ if (this.data?.progress_namedOperator !== undefined) {
183
+ const p = Progress.From(txb, obj?.get_object(), permission??this.data?.permission, this.data?.progress_namedOperator.progress);
184
+ this.data.progress_namedOperator.data.forEach(v => p.set_namedOperator(v.name, v.operator, passport));
177
185
  }
178
- if (this?.progress_parent !== undefined) {
179
- if (this.progress_parent.parent) {
180
- Progress.From(txb, this?.object, permission??this?.permission, this?.progress_parent.progress).parent(this.progress_parent.parent);
186
+ if (this.data?.progress_parent !== undefined) {
187
+ if (this.data.progress_parent.parent) {
188
+ Progress.From(txb, obj?.get_object(), permission??this.data?.permission, this.data?.progress_parent.progress).parent(this.data.progress_parent.parent);
181
189
  } else {
182
- Progress.From(txb, this?.object, permission??this?.permission, this?.progress_parent.progress).parent_none();
190
+ Progress.From(txb, obj?.get_object(), permission??this.data?.permission, this.data?.progress_parent.progress).parent_none();
183
191
  }
184
192
  }
185
- if (this?.progress_task !== undefined) {
186
- Progress.From(txb, this?.object, permission??this?.permission, this?.progress_task.progress).bind_task(this.progress_task.task, passport)
193
+ if (this.data?.progress_task !== undefined) {
194
+ Progress.From(txb, obj?.get_object(), permission??this.data?.permission, this.data?.progress_task.progress).bind_task(this.data.progress_task.task, passport)
187
195
  }
188
- if (this?.progress_hold !== undefined) {
189
- if (this?.progress_hold.adminUnhold) {
190
- Progress.From(txb, this?.object, permission??this?.permission, this?.progress_hold.progress).unhold(this.progress_hold.data, passport)
196
+ if (this.data?.progress_hold !== undefined) {
197
+ if (this.data?.progress_hold.adminUnhold) {
198
+ Progress.From(txb, obj?.get_object(), permission??this.data?.permission, this.data?.progress_hold.progress).unhold(this.data.progress_hold.data, passport)
191
199
  } else {
192
- Progress.From(txb, this?.object, permission??this?.permission, this?.progress_hold.progress).hold(this.progress_hold.data, this.progress_hold.bHold)
200
+ Progress.From(txb, obj?.get_object(), permission??this.data?.permission, this.data?.progress_hold.progress).hold(this.data.progress_hold.data, this.data.progress_hold.bHold)
193
201
  }
194
202
  }
195
- if (this?.progress_next !== undefined) {
196
- Progress.From(txb, this?.object, permission??this?.permission, this?.progress_next.progress).next(this.progress_next.data, this.progress_next.deliverable, passport)
203
+ if (this.data?.progress_next !== undefined) {
204
+ Progress.From(txb, obj?.get_object(), permission??this.data?.permission, this.data?.progress_next.progress).next(this.data.progress_next.data, this.data.progress_next.deliverable, passport)
197
205
  }
198
- if (this?.permission_new !== undefined ) {
199
- obj?.change_permission(this.permission_new);
206
+ if (this.data?.permission_new !== undefined ) {
207
+ obj?.change_permission(this.data.permission_new);
200
208
  }
201
209
  if (permission) {
202
210
  permission.launch();
203
211
  }
204
- if (this.object === 'new') {
212
+ if (!this.data.object) {
205
213
  obj?.launch();
206
214
  }
207
215
  }
@@ -1,10 +1,11 @@
1
- import { CallBase } from "./call";
1
+ import { CallBase, CallResult } from "./base";
2
2
  import { TransactionBlock, CallResponse} from 'wowok';
3
3
  import { PassportObject, IsValidAddress, Errors, ERROR, Permission, Permission_Entity, Permission_Index, UserDefinedIndex,
4
4
  PermissionIndexType, WitnessFill
5
5
  } from 'wowok';
6
6
 
7
- export class CallPermission extends CallBase {
7
+ export interface CallPermission_Data {
8
+ object?: string; // undefined for creating a new object
8
9
  builder?: string;
9
10
  admin?: {op:'add' | 'remove' | 'set', admins:string[]};
10
11
  description?: string;
@@ -12,88 +13,95 @@ export class CallPermission extends CallBase {
12
13
  | {op:'remove entity'; addresses:string[]} | {op:'remove permission'; address:string; index:PermissionIndexType[]}
13
14
  | {op:'transfer permission', from_address: string; to_address: string};
14
15
  biz_permission?: {op:'add'; data: UserDefinedIndex[]} | {op:'remove'; permissions: PermissionIndexType[]};
15
- constructor(object: string | 'new' = 'new') { super(object) }
16
- async call(account?:string) : Promise<WitnessFill[] | CallResponse | undefined> {
16
+ }
17
+ export class CallPermission extends CallBase {
18
+ data: CallPermission_Data;
19
+ constructor(data:CallPermission_Data) {
20
+ super();
21
+ this.data = data;
22
+ }
23
+
24
+ async call(account?:string) : Promise<CallResult> {
17
25
  var checkOwner = false; var checkAdmin = false;
18
- if (this?.object !== 'new' && IsValidAddress(this?.object)) {
19
- if (this?.builder !== undefined || this?.admin !== undefined) {
26
+ if (this.data?.object && IsValidAddress(this.data?.object)) {
27
+ if (this.data?.builder !== undefined || this.data?.admin !== undefined) {
20
28
  checkOwner = true;
21
29
  }
22
- if (this?.entity !== undefined || this?.biz_permission !== undefined) {
30
+ if (this.data?.entity !== undefined || this.data?.biz_permission !== undefined) {
23
31
  checkAdmin = true;
24
32
  }
25
- if (this?.description !== undefined && this?.object !== 'new') {
33
+ if (this.data?.description !== undefined) {
26
34
  checkAdmin = true;
27
35
  }
28
- return await this.check_permission_and_call(this.object, [], [], checkOwner, checkAdmin, account)
36
+ return await this.check_permission_and_call(this.data.object, [], [], checkOwner, checkAdmin, account)
29
37
  }
30
38
  return this.exec(account)
31
39
  }
32
40
  protected async operate (txb:TransactionBlock, passport?:PassportObject) {
33
41
  let obj : Permission | undefined ;
34
- if (this.object === 'new') {
35
- obj = Permission.New(txb, this?.description??'');
42
+ if (!this.data.object) {
43
+ obj = Permission.New(txb, this.data?.description??'');
36
44
  } else {
37
- if (IsValidAddress(this.object)) {
38
- obj = Permission.From(txb, this.object)
45
+ if (IsValidAddress(this.data.object)) {
46
+ obj = Permission.From(txb, this.data.object)
39
47
  }
40
48
  }
41
49
 
42
50
  if (obj) {
43
- if (this?.admin !== undefined) {
44
- switch(this.admin.op) {
51
+ if (this.data?.admin !== undefined) {
52
+ switch(this.data.admin.op) {
45
53
  case 'add':
46
- obj?.add_admin(this.admin.admins);
54
+ obj?.add_admin(this.data.admin.admins);
47
55
  break;
48
56
  case 'remove':
49
- obj?.remove_admin(this.admin.admins);
57
+ obj?.remove_admin(this.data.admin.admins);
50
58
  break;
51
59
  case 'set':
52
60
  obj?.remove_admin([], true);
53
- obj?.add_admin(this.admin.admins);
61
+ obj?.add_admin(this.data.admin.admins);
54
62
  break
55
63
  }
56
64
  }
57
- if (this?.description !== undefined && this.object !== 'new') {
58
- obj?.set_description(this.description)
65
+ if (this.data?.description !== undefined && this.data.object) {
66
+ obj?.set_description(this.data.description)
59
67
  }
60
- if (this?.entity !== undefined) {
61
- switch (this.entity.op) {
68
+ if (this.data?.entity !== undefined) {
69
+ switch (this.data.entity.op) {
62
70
  case 'add entity':
63
- obj?.add_entity(this.entity.entities);
71
+ obj?.add_entity(this.data.entity.entities);
64
72
  break;
65
73
  case 'add permission':
66
- obj?.add_entity3(this.entity.permissions);
74
+ obj?.add_entity3(this.data.entity.permissions);
67
75
  break;
68
76
  case 'remove entity':
69
- obj?.remove_entity(this.entity.addresses);
77
+ obj?.remove_entity(this.data.entity.addresses);
70
78
  break;
71
79
  case 'remove permission':
72
- obj?.remove_index(this.entity.address, this.entity.index);
80
+ obj?.remove_index(this.data.entity.address, this.data.entity.index);
73
81
  break;
74
82
  case 'transfer permission':
75
- obj?.transfer_permission(this.entity.from_address, this.entity.to_address);
83
+ obj?.transfer_permission(this.data.entity.from_address, this.data.entity.to_address);
76
84
  break;
77
85
  }
78
86
  }
79
- if (this?.biz_permission !== undefined) {
80
- switch(this.biz_permission.op) {
87
+ if (this.data?.biz_permission !== undefined) {
88
+ switch(this.data.biz_permission.op) {
81
89
  case 'add':
82
- this.biz_permission.data.forEach(v => {
90
+ this.data.biz_permission.data.forEach(v => {
83
91
  obj?.add_userdefine(v.index, v.name);
84
92
  })
85
93
  break;
86
94
  case 'remove':
87
- this.biz_permission.permissions.forEach(v => {
95
+ this.data.biz_permission.permissions.forEach(v => {
88
96
  obj?.remove_userdefine(v);
89
97
  })
90
98
  break;
91
99
  }
92
100
  }
93
- if (this?.builder !== undefined ) {
94
- obj?.change_owner(this.builder);
101
+ if (this.data?.builder !== undefined ) {
102
+ obj?.change_owner(this.data.builder);
95
103
  }
96
- if (this.object === 'new') {
104
+ if (!this.data.object) {
97
105
  obj?.launch();
98
106
  }
99
107
  }
@@ -1,8 +1,9 @@
1
1
  import { TransactionBlock, CallResponse} from 'wowok';
2
2
  import { PassportObject, IsValidAddress, Errors, ERROR, Entity, Entity_Info, MarkName, Resource, WitnessFill} from 'wowok';
3
- import { CallBase } from "./call";
3
+ import { CallBase, CallResult } from "./base";
4
4
 
5
- export class CallPersonal extends CallBase {
5
+ export interface CallPersonal_Data {
6
+ object?: string; // undefined for creating a new object
6
7
  information?: Entity_Info;
7
8
  transfer_to?: string;
8
9
  marks?: {op:'add mark'; data:{mark_name:string; address:string[]}}
@@ -13,73 +14,80 @@ export class CallPersonal extends CallBase {
13
14
  tags?: {op:'add'; data:{address:string; nick_name:string; tags:string[]}}
14
15
  | {op:'remove'; address:string};
15
16
  close?: boolean; // close a personal resource
16
- constructor(object: string | 'new' = 'new') { super(object) }
17
- async call(account?:string) : Promise<WitnessFill[] | CallResponse | undefined> {
17
+ }
18
+
19
+ export class CallEntity extends CallBase {
20
+ data: CallPersonal_Data;
21
+ constructor(data: CallPersonal_Data) {
22
+ super();
23
+ this.data = data;
24
+ }
25
+ async call(account?:string) : Promise<CallResult> {
18
26
  return this.exec(account)
19
27
  }
20
28
  protected async operate (txb:TransactionBlock, passport?:PassportObject) {
21
29
  let obj : Resource | undefined ; let entity: Entity = Entity.From(txb);
22
- if (this.object === 'new') {
30
+ if (!this.data.object) {
23
31
  obj = Resource.From(txb, entity.create_resource2());
24
32
  } else {
25
- if (IsValidAddress(this.object)) {
26
- obj = Resource.From(txb, this.object)
27
- if (this?.close) {
33
+ if (IsValidAddress(this.data.object)) {
34
+ obj = Resource.From(txb, this.data.object)
35
+ if (this.data?.close) {
28
36
  entity.destroy_resource(obj)
29
37
  return ; //@ return
30
38
  }
31
39
  }
32
40
  }
33
41
 
34
- if (this?.information !== undefined ) {
35
- entity.update(this.information)
42
+ if (this.data?.information !== undefined ) {
43
+ entity.update(this.data.information)
36
44
  }
37
45
 
38
46
  if (obj && obj?.get_object()) {
39
- if (this?.marks !== undefined) {
40
- switch(this.marks.op) {
47
+ if (this.data?.marks !== undefined) {
48
+ switch(this.data.marks.op) {
41
49
  case 'add address':
42
- obj?.add2(this.marks.data.address, this.marks.data.mark_name)
50
+ obj?.add2(this.data.marks.data.address, this.data.marks.data.mark_name)
43
51
  break;
44
52
  case 'add mark':
45
- if (this.marks.data.mark_name === MarkName.DislikeName || this.marks.data.mark_name === MarkName.LikeName) {
46
- const n = this.marks.data.mark_name;
47
- this.marks.data.address.forEach(v => {if (obj) entity.mark(obj, v, n)})
53
+ if (this.data.marks.data.mark_name === MarkName.DislikeName || this.data.marks.data.mark_name === MarkName.LikeName) {
54
+ const n = this.data.marks.data.mark_name;
55
+ this.data.marks.data.address.forEach(v => {if (obj) entity.mark(obj, v, n)})
48
56
  } else {
49
- obj?.add(this.marks.data.mark_name, this.marks.data.address)
57
+ obj?.add(this.data.marks.data.mark_name, this.data.marks.data.address)
50
58
  }
51
59
  break;
52
60
  case 'clear mark':
53
- obj?.remove(this.marks.mark_name, [], true)
61
+ obj?.remove(this.data.marks.mark_name, [], true)
54
62
  break;
55
63
  case 'remove address':
56
- obj?.remove2(this.marks.data.address, this.marks.data.mark_name)
64
+ obj?.remove2(this.data.marks.data.address, this.data.marks.data.mark_name)
57
65
  break;
58
66
  case 'remove mark':
59
- if (this.marks.data.mark_name === MarkName.DislikeName || this.marks.data.mark_name === MarkName.LikeName) {
60
- const n = this.marks.data.mark_name;
61
- this.marks.data.address.forEach(v => {if (obj) entity.mark(obj, v, n)})
67
+ if (this.data.marks.data.mark_name === MarkName.DislikeName || this.data.marks.data.mark_name === MarkName.LikeName) {
68
+ const n = this.data.marks.data.mark_name;
69
+ this.data.marks.data.address.forEach(v => {if (obj) entity.mark(obj, v, n)})
62
70
  } else {
63
- obj?.remove(this.marks.data.mark_name, this.marks.data.address)
71
+ obj?.remove(this.data.marks.data.mark_name, this.data.marks.data.address)
64
72
  }
65
73
  break;
66
74
  }
67
75
  }
68
- if (this?.tags !== undefined) {
69
- switch(this.tags.op) {
76
+ if (this.data?.tags !== undefined) {
77
+ switch(this.data.tags.op) {
70
78
  case 'add':
71
- obj?.add_tags(this.tags.data.address, this.tags.data.nick_name, this.tags.data.tags)
79
+ obj?.add_tags(this.data.tags.data.address, this.data.tags.data.nick_name, this.data.tags.data.tags)
72
80
  break;
73
81
  case 'remove':
74
- obj?.remove_tags(this.tags.address)
82
+ obj?.remove_tags(this.data.tags.address)
75
83
  break;
76
84
  }
77
85
  }
78
- if (this?.transfer_to !== undefined && obj) {
79
- entity.transfer_resource(obj, this.transfer_to);
86
+ if (this.data?.transfer_to !== undefined && obj) {
87
+ entity.transfer_resource(obj, this.data.transfer_to);
80
88
  }
81
89
 
82
- if (this.object === 'new') {
90
+ if (!this.data.object) {
83
91
  obj?.launch();
84
92
  }
85
93
  }