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