wowok_agent 1.3.47 → 1.3.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/call/arbitration.d.ts +1 -0
  2. package/dist/call/arbitration.d.ts.map +1 -1
  3. package/dist/call/arbitration.js +137 -131
  4. package/dist/call/arbitration.js.map +1 -1
  5. package/dist/call/base.d.ts +4 -2
  6. package/dist/call/base.d.ts.map +1 -1
  7. package/dist/call/base.js +12 -4
  8. package/dist/call/base.js.map +1 -1
  9. package/dist/call/demand.d.ts +1 -0
  10. package/dist/call/demand.d.ts.map +1 -1
  11. package/dist/call/demand.js +86 -80
  12. package/dist/call/demand.js.map +1 -1
  13. package/dist/call/machine.d.ts +1 -0
  14. package/dist/call/machine.d.ts.map +1 -1
  15. package/dist/call/machine.js +156 -146
  16. package/dist/call/machine.js.map +1 -1
  17. package/dist/call/permission.d.ts +3 -2
  18. package/dist/call/permission.d.ts.map +1 -1
  19. package/dist/call/permission.js +90 -85
  20. package/dist/call/permission.js.map +1 -1
  21. package/dist/call/repository.d.ts +1 -0
  22. package/dist/call/repository.d.ts.map +1 -1
  23. package/dist/call/repository.js +102 -92
  24. package/dist/call/repository.js.map +1 -1
  25. package/dist/call/service.d.ts +1 -0
  26. package/dist/call/service.d.ts.map +1 -1
  27. package/dist/call/service.js +272 -262
  28. package/dist/call/service.js.map +1 -1
  29. package/dist/call/treasury.d.ts +1 -0
  30. package/dist/call/treasury.d.ts.map +1 -1
  31. package/dist/call/treasury.js +108 -97
  32. package/dist/call/treasury.js.map +1 -1
  33. package/package.json +1 -1
  34. package/src/call/arbitration.ts +140 -135
  35. package/src/call/base.ts +12 -6
  36. package/src/call/demand.ts +89 -81
  37. package/src/call/machine.ts +153 -141
  38. package/src/call/permission.ts +93 -85
  39. package/src/call/repository.ts +104 -92
  40. package/src/call/service.ts +272 -261
  41. package/src/call/treasury.ts +108 -96
  42. package/tsconfig.tsbuildinfo +1 -1
@@ -1,6 +1,7 @@
1
1
  import { TransactionBlock, PassportObject, Errors, ERROR, Permission, PermissionIndex,
2
2
  PermissionIndexType, Repository, Repository_Policy, Repository_Policy_Data, Repository_Policy_Data2,
3
- Repository_Policy_Data_Remove, Repository_Policy_Mode, Repository_Value,
3
+ Repository_Policy_Data_Remove, Repository_Policy_Mode, Repository_Value,
4
+ PermissionObject,
4
5
  } from 'wowok';
5
6
  import { CallBase, CallResult, GetObjectExisted, GetObjectMain, GetObjectParam, ObjectMain, TypeNamedObjectWithPermission} from "./base.js";
6
7
  import { LocalMark } from '../local/local.js';
@@ -26,19 +27,24 @@ export class CallRepository extends CallBase {
26
27
  this.data = data;
27
28
  }
28
29
 
30
+ protected async prepare(): Promise<void> {
31
+ if (!this.object_address) {
32
+ this.object_address = (await LocalMark.Instance().get(GetObjectExisted(this.data?.object)))?.address;
33
+ if (this.object_address) {
34
+ await this.update_content('Repository', this.object_address);
35
+ if (!this.content) ERROR(Errors.InvalidParam, 'CallRepository_Data.data.object:' + this.object_address);
36
+ this.permission_address = (this.content as ObjectRepository).permission;
37
+ } else {
38
+ const n = GetObjectMain(this.data?.object) as TypeNamedObjectWithPermission;
39
+ this.permission_address = (await LocalMark.Instance().get_address(GetObjectExisted(n?.permission)));
40
+ }
41
+ }
42
+ }
29
43
  async call(account?:string) : Promise<CallResult> {
30
44
  var checkOwner = false;
31
45
  const perms : PermissionIndexType[] = [];
32
- this.object_address = (await LocalMark.Instance().get(GetObjectExisted(this.data?.object)))?.address;
33
- if (this.object_address) {
34
- await this.update_content('Repository', this.object_address);
35
- if (!this.content) ERROR(Errors.InvalidParam, 'CallRepository_Data.data.object:' + this.object_address);
36
- this.permission_address = (this.content as ObjectRepository).permission;
37
- } else {
38
- const n = GetObjectMain(this.data?.object) as TypeNamedObjectWithPermission;
39
- this.permission_address = (await LocalMark.Instance().get_address(GetObjectExisted(n?.permission)));
40
- }
41
46
 
47
+ await this.prepare();
42
48
  if (this.permission_address) {
43
49
  if (!this.data?.object) {
44
50
  perms.push(PermissionIndex.repository)
@@ -61,103 +67,109 @@ export class CallRepository extends CallBase {
61
67
  }
62
68
 
63
69
  protected async operate(txb:TransactionBlock, passport?:PassportObject, account?:string) {
64
- let obj : Repository | undefined ; let permission: any;
70
+ let obj : Repository | undefined ; let perm: Permission | undefined;
71
+ let permission : PermissionObject | undefined;
72
+
65
73
  if (this.object_address) {
66
74
  obj = Repository.From(txb, this.permission_address!, this.object_address);
75
+ permission = this.permission_address;
67
76
  } else {
68
77
  const n = GetObjectMain(this.data?.object) as TypeNamedObjectWithPermission;
69
- if (!this.permission_address) {
70
- permission = Permission.New(txb, GetObjectParam(n?.permission)?.description ?? '');
78
+ permission = await LocalMark.Instance().get_address(GetObjectExisted(n?.permission));
79
+ if (!permission) {
80
+ perm = Permission.New(txb, GetObjectParam(n?.permission)?.description ?? '');
81
+ permission = perm.get_object();
71
82
  }
72
83
 
73
- obj = Repository.New(txb, permission ? permission.get_object() : this.permission_address, this.data?.description??'',
74
- this.data.mode, permission?undefined:passport);
84
+ obj = Repository.New(txb, permission, this.data?.description??'',
85
+ this.data.mode, perm?undefined:passport);
75
86
  }
76
87
 
77
- if (obj) {
78
- const pst = permission?undefined:passport;
79
- if (this.data?.description !== undefined && this.object_address) {
80
- obj?.set_description(this.data.description, pst);
81
- }
82
- if (this.data?.reference !== undefined) {
83
- switch (this.data.reference.op) {
84
- case 'set':
85
- case 'add':
86
- if (this.data.reference.op === 'set') obj?.remove_reference([], true, pst);
87
- obj?.add_reference(await LocalMark.Instance().get_many_address2(this.data.reference.addresses), pst);
88
- break;
89
- case 'remove':
90
- obj?.remove_reference(await LocalMark.Instance().get_many_address2(this.data.reference.addresses), false, pst);
91
- break;
92
- case 'removeall':
93
- obj?.remove_reference([], true, pst);
94
- break;
95
- }
96
- }
97
- if (this.data?.mode !== undefined && this.object_address) { //@ priority??
98
- obj?.set_policy_mode(this.data.mode, pst)
88
+ if (!obj) ERROR(Errors.InvalidParam, 'CallRepository_Data.object:' + this.object_address);
89
+ if (!permission) ERROR(Errors.InvalidParam, 'CallRepository_Data.permission:' + this.permission_address);
90
+
91
+ const pst = perm?undefined:passport;
92
+ if (this.data?.description !== undefined && this.object_address) {
93
+ obj?.set_description(this.data.description, pst);
94
+ }
95
+ if (this.data?.reference !== undefined) {
96
+ switch (this.data.reference.op) {
97
+ case 'set':
98
+ case 'add':
99
+ if (this.data.reference.op === 'set') obj?.remove_reference([], true, pst);
100
+ obj?.add_reference(await LocalMark.Instance().get_many_address2(this.data.reference.addresses), pst);
101
+ break;
102
+ case 'remove':
103
+ obj?.remove_reference(await LocalMark.Instance().get_many_address2(this.data.reference.addresses), false, pst);
104
+ break;
105
+ case 'removeall':
106
+ obj?.remove_reference([], true, pst);
107
+ break;
99
108
  }
100
- if (this.data?.policy !== undefined) {
101
- switch(this.data.policy.op) {
102
- case 'set':
103
- obj?.remove_policies([], true, pst);
104
- obj?.add_policies(this.data.policy.data, pst);
105
- break;
106
- case 'add':
107
- obj?.add_policies(this.data.policy.data, pst);
108
- break;
109
- case 'remove':
110
- obj?.remove_policies(this.data.policy.keys, false, pst);
111
- break;
112
- case 'removeall':
113
- obj?.remove_policies([], true, pst);
114
- break;
115
- case 'rename':
116
- this.data.policy.data.forEach((v) => {
117
- obj?.rename_policy(v.old, v.new, pst);
118
- })
119
- break;
120
- }
109
+ }
110
+ if (this.data?.mode !== undefined && this.object_address) { //@ priority??
111
+ obj?.set_policy_mode(this.data.mode, pst)
112
+ }
113
+ if (this.data?.policy !== undefined) {
114
+ switch(this.data.policy.op) {
115
+ case 'set':
116
+ obj?.remove_policies([], true, pst);
117
+ obj?.add_policies(this.data.policy.data, pst);
118
+ break;
119
+ case 'add':
120
+ obj?.add_policies(this.data.policy.data, pst);
121
+ break;
122
+ case 'remove':
123
+ obj?.remove_policies(this.data.policy.keys, false, pst);
124
+ break;
125
+ case 'removeall':
126
+ obj?.remove_policies([], true, pst);
127
+ break;
128
+ case 'rename':
129
+ this.data.policy.data.forEach((v) => {
130
+ obj?.rename_policy(v.old, v.new, pst);
131
+ })
132
+ break;
121
133
  }
122
- if (this.data?.data !== undefined) {
123
- switch(this.data.data.op) {
124
- case 'add':
125
- if ((this.data.data?.data as any)?.key !== undefined) {
126
- const d = (this.data.data.data as Repository_Policy_Data).data;
127
- const add: Repository_Value[] = [];
128
- for (let i=0; i<d.length; ++i) {
129
- const addr = await LocalMark.Instance().get_address(d[i].address);
130
- if (addr) {
131
- add.push({address:addr, bcsBytes:d[i].bcsBytes});
132
- }
133
- }
134
- obj?.add_data({key:(this.data.data.data as Repository_Policy_Data).key, data:add, value_type:(this.data.data.data as Repository_Policy_Data).value_type});
135
- } else if ((this.data.data?.data as any)?.address !== undefined) {
136
- const d = this.data.data.data as Repository_Policy_Data2;
137
- const addr = await LocalMark.Instance().get_address(d.address);
134
+ }
135
+ if (this.data?.data !== undefined) {
136
+ switch(this.data.data.op) {
137
+ case 'add':
138
+ if ((this.data.data?.data as any)?.key !== undefined) {
139
+ const d = (this.data.data.data as Repository_Policy_Data).data;
140
+ const add: Repository_Value[] = [];
141
+ for (let i=0; i<d.length; ++i) {
142
+ const addr = await LocalMark.Instance().get_address(d[i].address);
138
143
  if (addr) {
139
- obj?.add_data2({address:addr, data:d.data, value_type:d.value_type})
144
+ add.push({address:addr, bcsBytes:d[i].bcsBytes});
140
145
  }
141
146
  }
142
- break;
143
- case 'remove':
144
- for (let i=0; i<this.data.data.data.length; ++i) {
145
- const addr = await LocalMark.Instance().get_address(this.data.data.data[i].address);
146
- if (addr) {
147
- obj?.remove(addr, this.data.data.data[i].key);
148
- }
147
+ obj?.add_data({key:(this.data.data.data as Repository_Policy_Data).key, data:add, value_type:(this.data.data.data as Repository_Policy_Data).value_type});
148
+ } else if ((this.data.data?.data as any)?.address !== undefined) {
149
+ const d = this.data.data.data as Repository_Policy_Data2;
150
+ const addr = await LocalMark.Instance().get_address(d.address);
151
+ if (addr) {
152
+ obj?.add_data2({address:addr, data:d.data, value_type:d.value_type})
153
+ }
154
+ }
155
+ break;
156
+ case 'remove':
157
+ for (let i=0; i<this.data.data.data.length; ++i) {
158
+ const addr = await LocalMark.Instance().get_address(this.data.data.data[i].address);
159
+ if (addr) {
160
+ obj?.remove(addr, this.data.data.data[i].key);
149
161
  }
150
- break;
151
- }
162
+ }
163
+ break;
152
164
  }
165
+ }
153
166
 
154
- if (permission) {
155
- const n = GetObjectMain(this.data?.object) as TypeNamedObjectWithPermission;
156
- await this.new_with_mark('Permission', txb, permission.launch(), GetObjectParam(n?.permission), account);
157
- }
158
- if (!this.object_address) {
159
- await this.new_with_mark('Repository', txb, obj.launch(), GetObjectMain(this.data?.object), account);
160
- }
167
+ if (perm) {
168
+ const n = GetObjectMain(this.data?.object) as TypeNamedObjectWithPermission;
169
+ await this.new_with_mark('Permission', txb, perm.launch(), GetObjectParam(n?.permission), account);
170
+ }
171
+ if (!this.object_address) {
172
+ await this.new_with_mark('Repository', txb, obj.launch(), GetObjectMain(this.data?.object), account);
161
173
  }
162
- };
174
+ }
163
175
  }