wowok_agent 1.2.45 → 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 +14 -28
- package/dist/call/arbitration.d.ts.map +1 -1
- package/dist/call/arbitration.js +158 -145
- package/dist/call/arbitration.js.map +1 -1
- package/dist/call/base.d.ts +33 -2
- package/dist/call/base.d.ts.map +1 -1
- package/dist/call/base.js +49 -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 +10 -22
- package/dist/call/demand.d.ts.map +1 -1
- package/dist/call/demand.js +107 -109
- package/dist/call/demand.js.map +1 -1
- package/dist/call/machine.d.ts +36 -44
- package/dist/call/machine.d.ts.map +1 -1
- package/dist/call/machine.js +179 -179
- 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 +31 -18
- package/dist/call/permission.d.ts.map +1 -1
- package/dist/call/permission.js +92 -86
- 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 +5 -12
- package/dist/call/repository.d.ts.map +1 -1
- package/dist/call/repository.js +114 -92
- package/dist/call/repository.js.map +1 -1
- package/dist/call/service.d.ts +51 -70
- package/dist/call/service.d.ts.map +1 -1
- package/dist/call/service.js +335 -302
- package/dist/call/service.js.map +1 -1
- package/dist/call/treasury.d.ts +23 -26
- package/dist/call/treasury.d.ts.map +1 -1
- package/dist/call/treasury.js +124 -112
- 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/objects.d.ts +6 -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 +178 -161
- package/src/call/base.ts +84 -10
- package/src/call/call.ts +6 -0
- package/src/call/demand.ts +120 -121
- package/src/call/machine.ts +193 -194
- package/src/call/object_permission.ts +1 -1
- package/src/call/permission.ts +121 -90
- package/src/call/personal.ts +18 -20
- package/src/call/repository.ts +120 -101
- package/src/call/service.ts +375 -325
- package/src/call/treasury.ts +143 -121
- package/src/common.ts +7 -1
- package/src/local/account.ts +1 -1
- package/src/local/local.ts +6 -2
- package/src/query/objects.ts +17 -4
- package/tsconfig.tsbuildinfo +1 -1
package/src/call/permission.ts
CHANGED
|
@@ -1,21 +1,45 @@
|
|
|
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,
|
|
4
|
+
ObjectPermissionMain} from "./base.js";
|
|
5
|
+
import { PassportObject, Permission, BizPermission,
|
|
6
|
+
PermissionIndexType, TransactionBlock, Permission_Entity as Wowok_Permission_Entity,
|
|
7
|
+
Permission_Index as Wowok_Permission_Index, Permission_Index_Entity as Wowok_Permission_Index_Entity,
|
|
8
|
+
ERROR,
|
|
9
|
+
Errors,
|
|
7
10
|
} from 'wowok';
|
|
8
11
|
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
export interface Entity_Permission {
|
|
15
|
+
index: PermissionIndexType;
|
|
16
|
+
guard?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface Permission_Entity {
|
|
20
|
+
entity: AccountOrMark_Address;
|
|
21
|
+
permissions:Entity_Permission[];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface Permission_Index_Entity {
|
|
25
|
+
entity: AccountOrMark_Address;
|
|
26
|
+
guard?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface Permission_Index {
|
|
30
|
+
index: PermissionIndexType;
|
|
31
|
+
entities: Permission_Index_Entity[];
|
|
32
|
+
}
|
|
9
33
|
/// The execution priority is determined by the order in which the object attributes are arranged
|
|
10
34
|
export interface CallPermission_Data {
|
|
11
|
-
object?:
|
|
35
|
+
object?: ObjectPermissionMain;
|
|
12
36
|
description?: string;
|
|
13
|
-
admin?: {op:'add' | 'remove' | 'set', addresses:string[]} | {op:'removeall'};
|
|
14
37
|
biz_permission?: {op:'add'; data: BizPermission[]} | {op:'remove'; permissions: PermissionIndexType[]};
|
|
15
38
|
permission?: {op:'add entity'; entities:Permission_Entity[]} | {op:'add permission'; permissions:Permission_Index[]}
|
|
16
|
-
| {op:'remove entity';
|
|
17
|
-
| {op:'transfer permission',
|
|
18
|
-
|
|
39
|
+
| {op:'remove entity'; entities:AccountOrMark_Address[]} | {op:'remove permission'; entity:AccountOrMark_Address; index:PermissionIndexType[]}
|
|
40
|
+
| {op:'transfer permission', from_entity: AccountOrMark_Address; to_entity: AccountOrMark_Address};
|
|
41
|
+
admin?: {op:'add' | 'remove' | 'set', entities:AccountOrMark_Address[]} | {op:'removeall'};
|
|
42
|
+
builder?: AccountOrMark_Address;
|
|
19
43
|
}
|
|
20
44
|
export class CallPermission extends CallBase {
|
|
21
45
|
data: CallPermission_Data;
|
|
@@ -25,10 +49,15 @@ export class CallPermission extends CallBase {
|
|
|
25
49
|
this.data = data;
|
|
26
50
|
}
|
|
27
51
|
|
|
52
|
+
protected async prepare(): Promise<void> {
|
|
53
|
+
if (!this.object_address) {
|
|
54
|
+
this.object_address = await LocalMark.Instance().get_address(GetObjectExisted(this.data?.object));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
28
57
|
async call(account?:string) : Promise<CallResult> {
|
|
29
58
|
var checkOwner = false; var checkAdmin = false;
|
|
30
|
-
|
|
31
|
-
|
|
59
|
+
|
|
60
|
+
await this.prepare();
|
|
32
61
|
if (this.object_address) {
|
|
33
62
|
if (this.data?.builder !== undefined || this.data?.admin !== undefined) {
|
|
34
63
|
checkOwner = true;
|
|
@@ -52,90 +81,92 @@ export class CallPermission extends CallBase {
|
|
|
52
81
|
obj = Permission.From(txb, this.object_address)
|
|
53
82
|
}
|
|
54
83
|
|
|
55
|
-
if (obj)
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
obj?.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
obj?.remove_admin([], true);
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
if (this.data?.biz_permission !== undefined) { // High priority operate
|
|
77
|
-
switch(this.data.biz_permission.op) {
|
|
78
|
-
case 'add':
|
|
79
|
-
this.data.biz_permission.data.forEach(v => {
|
|
80
|
-
obj?.add_bizPermission(v.index, v.name);
|
|
81
|
-
})
|
|
82
|
-
break;
|
|
83
|
-
case 'remove':
|
|
84
|
-
this.data.biz_permission.permissions.forEach(v => {
|
|
85
|
-
obj?.remove_bizPermission(v);
|
|
86
|
-
})
|
|
87
|
-
break;
|
|
88
|
-
}
|
|
84
|
+
if (!obj) ERROR(Errors.InvalidParam, 'CallPermission_Data.data.object');
|
|
85
|
+
|
|
86
|
+
if (this.data?.description !== undefined && this.data?.object) {
|
|
87
|
+
obj?.set_description(this.data.description)
|
|
88
|
+
}
|
|
89
|
+
if (this.data?.biz_permission !== undefined) { // High priority operate
|
|
90
|
+
switch(this.data.biz_permission.op) {
|
|
91
|
+
case 'add':
|
|
92
|
+
this.data.biz_permission.data.forEach(v => {
|
|
93
|
+
obj?.add_bizPermission(v.index, v.name);
|
|
94
|
+
})
|
|
95
|
+
break;
|
|
96
|
+
case 'remove':
|
|
97
|
+
this.data.biz_permission.permissions.forEach(v => {
|
|
98
|
+
obj?.remove_bizPermission(v);
|
|
99
|
+
})
|
|
100
|
+
break;
|
|
89
101
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
102
|
+
}
|
|
103
|
+
if (this.data?.permission !== undefined) {
|
|
104
|
+
switch (this.data.permission.op) {
|
|
105
|
+
case 'add entity':
|
|
106
|
+
var add_entity:Wowok_Permission_Entity[] = [];
|
|
107
|
+
for (let i = 0; i < this.data.permission.entities.length; ++i) {
|
|
108
|
+
const v = this.data.permission.entities[i];
|
|
109
|
+
const addr = await GetAccountOrMark_Address(v.entity);
|
|
110
|
+
if (addr) {
|
|
111
|
+
add_entity.push({address:addr, permissions:v.permissions});
|
|
101
112
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
113
|
+
}
|
|
114
|
+
obj?.add_entity(add_entity);
|
|
115
|
+
break;
|
|
116
|
+
case 'add permission':
|
|
117
|
+
var add_permission: Wowok_Permission_Index[] = [];
|
|
118
|
+
for (let i = 0; i < this.data.permission.permissions.length; ++i) {
|
|
119
|
+
const v = this.data.permission.permissions[i];
|
|
120
|
+
const e:Wowok_Permission_Index_Entity[] = [];
|
|
121
|
+
for (let j = 0; j < v.entities.length; ++j) {
|
|
122
|
+
const addr = await GetAccountOrMark_Address(v.entities[j].entity);
|
|
123
|
+
const guard = await LocalMark.Instance().get_address(v.entities[j].guard as string) ;
|
|
124
|
+
if (addr) {
|
|
125
|
+
e.push({address:addr, guard:guard})
|
|
114
126
|
}
|
|
115
|
-
v.entities = e;
|
|
116
127
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
if (b) obj?.change_owner(b.address);
|
|
128
|
+
add_permission.push({index:v.index, entities:e});
|
|
129
|
+
}
|
|
130
|
+
obj?.add_entity3(add_permission);
|
|
131
|
+
break;
|
|
132
|
+
case 'remove entity':
|
|
133
|
+
const entities:string[] = (await GetManyAccountOrMark_Address(this.data.permission.entities)).filter((v): v is string => v!== undefined);
|
|
134
|
+
obj?.remove_entity(entities);
|
|
135
|
+
break;
|
|
136
|
+
case 'remove permission':
|
|
137
|
+
const addr = await GetAccountOrMark_Address(this.data.permission.entity);
|
|
138
|
+
if (addr) obj?.remove_index(addr, this.data.permission.index);
|
|
139
|
+
break;
|
|
140
|
+
case 'transfer permission':
|
|
141
|
+
const from = await GetAccountOrMark_Address(this.data.permission.from_entity);
|
|
142
|
+
const to = await GetAccountOrMark_Address(this.data.permission.to_entity);
|
|
143
|
+
if (from && to) obj?.transfer_permission(from, to);
|
|
144
|
+
break;
|
|
135
145
|
}
|
|
136
|
-
|
|
137
|
-
|
|
146
|
+
}
|
|
147
|
+
if (this.data?.admin !== undefined) {
|
|
148
|
+
switch(this.data.admin?.op) {
|
|
149
|
+
case 'add':
|
|
150
|
+
case 'set':
|
|
151
|
+
if (this.data.admin?.op === 'set') obj?.remove_admin([], true);
|
|
152
|
+
const add = await GetManyAccountOrMark_Address(this.data.admin.entities);
|
|
153
|
+
obj?.add_admin(add.filter((v): v is string => v!== undefined));
|
|
154
|
+
break;
|
|
155
|
+
case 'remove':
|
|
156
|
+
const remove = await GetManyAccountOrMark_Address(this.data.admin.entities);
|
|
157
|
+
obj?.remove_admin(remove.filter((v): v is string => typeof(v) === 'string'));
|
|
158
|
+
break;
|
|
159
|
+
case 'removeall':
|
|
160
|
+
obj?.remove_admin([], true);
|
|
161
|
+
break;
|
|
138
162
|
}
|
|
139
163
|
}
|
|
164
|
+
if (this.data?.builder !== undefined ) {
|
|
165
|
+
const b = await GetAccountOrMark_Address(this.data.builder);
|
|
166
|
+
if (b) obj?.change_owner(b);
|
|
167
|
+
}
|
|
168
|
+
if (!this.object_address) {
|
|
169
|
+
await this.new_with_mark('Permission', txb, obj.launch(), GetObjectMain(this.data?.object), account);
|
|
170
|
+
}
|
|
140
171
|
}
|
|
141
172
|
}
|
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
|
|
package/src/call/repository.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { TransactionBlock, PassportObject,
|
|
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,
|
|
3
|
+
Repository_Policy_Data_Remove, Repository_Policy_Mode, Repository_Value,
|
|
4
|
+
PermissionObject,
|
|
4
5
|
} from 'wowok';
|
|
5
|
-
import { CallBase, CallResult,
|
|
6
|
+
import { CallBase, CallResult, GetObjectExisted, GetObjectMain, GetObjectParam, ObjectMain, TypeNamedObjectWithPermission} from "./base.js";
|
|
6
7
|
import { LocalMark } from '../local/local.js';
|
|
7
8
|
import { ObjectRepository } from '../query/objects.js';
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
/// The execution priority is determined by the order in which the object attributes are arranged
|
|
11
12
|
export interface CallRepository_Data {
|
|
12
|
-
object?:
|
|
13
|
-
permission?: {address:string} | {namedNew?: Namedbject, description?:string};
|
|
13
|
+
object?: ObjectMain;
|
|
14
14
|
description?: string;
|
|
15
15
|
reference?: {op:'set' | 'add' | 'remove' ; addresses:string[]} | {op:'removeall'};
|
|
16
16
|
mode?: Repository_Policy_Mode; // default: 'Relax' (POLICY_MODE_FREE)
|
|
@@ -19,36 +19,40 @@ export interface CallRepository_Data {
|
|
|
19
19
|
}
|
|
20
20
|
export class CallRepository extends CallBase {
|
|
21
21
|
data: CallRepository_Data;
|
|
22
|
+
object_address: string | undefined = undefined;
|
|
23
|
+
permission_address: string | undefined = undefined;
|
|
24
|
+
|
|
22
25
|
constructor(data:CallRepository_Data) {
|
|
23
26
|
super();
|
|
24
27
|
this.data = data;
|
|
25
28
|
}
|
|
26
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
|
+
}
|
|
27
43
|
async call(account?:string) : Promise<CallResult> {
|
|
28
44
|
var checkOwner = false;
|
|
29
45
|
const perms : PermissionIndexType[] = [];
|
|
30
|
-
var [permission_address, object_address] =
|
|
31
|
-
await LocalMark.Instance().get_many_address(
|
|
32
|
-
[(this.data?.permission as any)?.address,
|
|
33
|
-
(this.data?.object as any)?.address]);
|
|
34
|
-
|
|
35
|
-
if (object_address) {
|
|
36
|
-
if (!permission_address) {
|
|
37
|
-
await this.update_content(object_address, 'Repository');
|
|
38
|
-
if (this.content) {
|
|
39
|
-
permission_address = (this.content as ObjectRepository).permission;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
46
|
|
|
44
|
-
|
|
47
|
+
await this.prepare();
|
|
48
|
+
if (this.permission_address) {
|
|
45
49
|
if (!this.data?.object) {
|
|
46
50
|
perms.push(PermissionIndex.repository)
|
|
47
51
|
}
|
|
48
|
-
if (this.data?.description !== undefined && object_address) {
|
|
52
|
+
if (this.data?.description !== undefined && this.object_address) {
|
|
49
53
|
perms.push(PermissionIndex.repository_description)
|
|
50
54
|
}
|
|
51
|
-
if (this.data?.mode !== undefined && object_address) {
|
|
55
|
+
if (this.data?.mode !== undefined && this.object_address) {
|
|
52
56
|
perms.push(PermissionIndex.repository_mode)
|
|
53
57
|
}
|
|
54
58
|
if (this.data?.reference !== undefined) {
|
|
@@ -57,100 +61,115 @@ export class CallRepository extends CallBase {
|
|
|
57
61
|
if (this.data?.policy !== undefined) {
|
|
58
62
|
perms.push(PermissionIndex.repository_policies)
|
|
59
63
|
}
|
|
60
|
-
return await this.check_permission_and_call(permission_address, perms, [], checkOwner, undefined, account)
|
|
64
|
+
return await this.check_permission_and_call(this.permission_address, perms, [], checkOwner, undefined, account)
|
|
61
65
|
}
|
|
62
66
|
return await this.exec(account);
|
|
63
67
|
}
|
|
64
68
|
|
|
65
69
|
protected async operate(txb:TransactionBlock, passport?:PassportObject, account?:string) {
|
|
66
|
-
let obj : Repository | undefined ; let
|
|
67
|
-
|
|
68
|
-
[(this.content as ObjectRepository).permission, this.content.object] :
|
|
69
|
-
await LocalMark.Instance().get_many_address(
|
|
70
|
-
[(this.data?.permission as any)?.address,
|
|
71
|
-
(this.data?.object as any)?.address]);
|
|
70
|
+
let obj : Repository | undefined ; let perm: Permission | undefined;
|
|
71
|
+
let permission : PermissionObject | undefined;
|
|
72
72
|
|
|
73
|
-
if (
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
permission = Permission.New(txb, d);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
obj = Repository.New(txb, permission ? permission.get_object() : permission_address, this.data?.description??'', this.data?.mode, permission?undefined:passport)
|
|
73
|
+
if (this.object_address) {
|
|
74
|
+
obj = Repository.From(txb, this.permission_address!, this.object_address);
|
|
75
|
+
permission = this.permission_address;
|
|
80
76
|
} else {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
77
|
+
const n = GetObjectMain(this.data?.object) as TypeNamedObjectWithPermission;
|
|
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();
|
|
85
82
|
}
|
|
83
|
+
|
|
84
|
+
obj = Repository.New(txb, permission, this.data?.description??'',
|
|
85
|
+
this.data.mode, perm?undefined:passport);
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
if (obj)
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if (this.data?.mode !== undefined && object_address) { //@ priority??
|
|
109
|
-
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;
|
|
110
108
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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;
|
|
132
133
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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);
|
|
143
|
+
if (addr) {
|
|
144
|
+
add.push({address:addr, bcsBytes:d[i].bcsBytes});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
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})
|
|
140
153
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
break;
|
|
146
164
|
}
|
|
165
|
+
}
|
|
147
166
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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);
|
|
154
173
|
}
|
|
155
|
-
}
|
|
174
|
+
}
|
|
156
175
|
}
|