wowok_agent 1.3.47 → 1.3.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/call/arbitration.d.ts +1 -0
- package/dist/call/arbitration.d.ts.map +1 -1
- package/dist/call/arbitration.js +137 -131
- package/dist/call/arbitration.js.map +1 -1
- package/dist/call/base.d.ts +4 -2
- package/dist/call/base.d.ts.map +1 -1
- package/dist/call/base.js +12 -4
- package/dist/call/base.js.map +1 -1
- package/dist/call/demand.d.ts +1 -0
- package/dist/call/demand.d.ts.map +1 -1
- package/dist/call/demand.js +86 -80
- package/dist/call/demand.js.map +1 -1
- package/dist/call/machine.d.ts +1 -0
- package/dist/call/machine.d.ts.map +1 -1
- package/dist/call/machine.js +156 -146
- package/dist/call/machine.js.map +1 -1
- package/dist/call/permission.d.ts +3 -2
- package/dist/call/permission.d.ts.map +1 -1
- package/dist/call/permission.js +90 -85
- package/dist/call/permission.js.map +1 -1
- package/dist/call/repository.d.ts +1 -0
- package/dist/call/repository.d.ts.map +1 -1
- package/dist/call/repository.js +102 -92
- package/dist/call/repository.js.map +1 -1
- package/dist/call/service.d.ts +1 -0
- package/dist/call/service.d.ts.map +1 -1
- package/dist/call/service.js +272 -262
- package/dist/call/service.js.map +1 -1
- package/dist/call/treasury.d.ts +1 -0
- package/dist/call/treasury.d.ts.map +1 -1
- package/dist/call/treasury.js +108 -97
- package/dist/call/treasury.js.map +1 -1
- package/package.json +1 -1
- package/src/call/arbitration.ts +140 -135
- package/src/call/base.ts +12 -6
- package/src/call/demand.ts +89 -81
- package/src/call/machine.ts +153 -141
- package/src/call/permission.ts +93 -85
- package/src/call/repository.ts +104 -92
- package/src/call/service.ts +272 -261
- package/src/call/treasury.ts +108 -96
- package/tsconfig.tsbuildinfo +1 -1
package/src/call/repository.ts
CHANGED
|
@@ -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
|
|
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
|
-
|
|
70
|
-
|
|
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
|
|
74
|
-
this.data.mode,
|
|
84
|
+
obj = Repository.New(txb, permission, this.data?.description??'',
|
|
85
|
+
this.data.mode, perm?undefined:passport);
|
|
75
86
|
}
|
|
76
87
|
|
|
77
|
-
if (obj)
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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
|
-
|
|
144
|
+
add.push({address:addr, bcsBytes:d[i].bcsBytes});
|
|
140
145
|
}
|
|
141
146
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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
|
-
|
|
151
|
-
|
|
162
|
+
}
|
|
163
|
+
break;
|
|
152
164
|
}
|
|
165
|
+
}
|
|
153
166
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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
|
}
|