wowok_agent 1.3.47 → 1.3.49
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 +4 -3
- package/dist/call/arbitration.d.ts.map +1 -1
- package/dist/call/arbitration.js +134 -131
- package/dist/call/arbitration.js.map +1 -1
- package/dist/call/base.d.ts +15 -7
- package/dist/call/base.d.ts.map +1 -1
- package/dist/call/base.js +21 -23
- package/dist/call/base.js.map +1 -1
- package/dist/call/call.d.ts +0 -6
- package/dist/call/call.d.ts.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 +10 -10
- package/dist/call/machine.d.ts.map +1 -1
- package/dist/call/machine.js +174 -146
- package/dist/call/machine.js.map +1 -1
- package/dist/call/permission.d.ts +10 -9
- 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/personal.d.ts +3 -3
- package/dist/call/personal.d.ts.map +1 -1
- package/dist/call/personal.js +6 -12
- package/dist/call/personal.js.map +1 -1
- package/dist/call/repository.d.ts +24 -8
- package/dist/call/repository.d.ts.map +1 -1
- package/dist/call/repository.js +114 -94
- package/dist/call/repository.js.map +1 -1
- package/dist/call/service.d.ts +15 -26
- package/dist/call/service.d.ts.map +1 -1
- package/dist/call/service.js +274 -264
- package/dist/call/service.js.map +1 -1
- package/dist/call/treasury.d.ts +5 -7
- 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/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/query/objects.d.ts +2 -1
- package/dist/query/objects.d.ts.map +1 -1
- package/dist/query/objects.js +7 -7
- package/dist/query/objects.js.map +1 -1
- package/dist/query/owned.d.ts +2 -0
- package/dist/query/owned.d.ts.map +1 -0
- package/dist/query/owned.js +2 -0
- package/dist/query/owned.js.map +1 -0
- package/dist/query/permission.d.ts +3 -2
- package/dist/query/permission.d.ts.map +1 -1
- package/dist/query/permission.js +6 -3
- package/dist/query/permission.js.map +1 -1
- package/dist/query/treasury_received.d.ts +14 -0
- package/dist/query/treasury_received.d.ts.map +1 -0
- package/dist/query/treasury_received.js +19 -0
- package/dist/query/treasury_received.js.map +1 -0
- package/package.json +1 -1
- package/src/call/arbitration.ts +144 -141
- package/src/call/base.ts +27 -29
- package/src/call/call.ts +6 -6
- package/src/call/demand.ts +89 -81
- package/src/call/machine.ts +184 -145
- package/src/call/permission.ts +98 -90
- package/src/call/personal.ts +8 -13
- package/src/call/repository.ts +138 -95
- package/src/call/service.ts +290 -272
- package/src/call/treasury.ts +110 -99
- package/src/index.ts +1 -0
- package/src/query/objects.ts +10 -10
- package/src/query/permission.ts +9 -6
- package/src/query/treasury_received.ts +35 -0
- package/tsconfig.tsbuildinfo +1 -1
package/src/call/personal.ts
CHANGED
|
@@ -7,9 +7,9 @@ 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';
|
|
10
|
+
mark?: {op:'add'; data:{address:AccountOrMark_Address; name?:string; tags?:string[]}[]}
|
|
11
|
+
| {op:'remove'; data:{address:AccountOrMark_Address; tags?:string[]}[]}
|
|
12
|
+
| {op:'removeall'; addresses:AccountOrMark_Address[]}
|
|
13
13
|
| {op:'transfer'; to: AccountOrMark_Address}
|
|
14
14
|
| {op:'replace'; mark_object: string}
|
|
15
15
|
| {op:'destroy'}
|
|
@@ -25,13 +25,8 @@ export class CallPersonal extends CallBase {
|
|
|
25
25
|
return await this.exec(account)
|
|
26
26
|
}
|
|
27
27
|
protected async operate (txb:TransactionBlock, passport?:PassportObject, account?: string) {
|
|
28
|
-
const entity_address = (await Account.Instance().get(account))?.address;
|
|
29
|
-
if (!entity_address) {
|
|
30
|
-
ERROR(Errors.InvalidParam, 'account - ' + account)
|
|
31
|
-
};
|
|
32
|
-
|
|
33
28
|
let obj : Resource | undefined ; let entity: Entity = Entity.From(txb);
|
|
34
|
-
const entity_data = await query_personal({address:
|
|
29
|
+
const entity_data = await query_personal({address:{account_name:account}});
|
|
35
30
|
if (entity_data?.mark_object) {
|
|
36
31
|
obj = Resource.From(txb, entity_data.mark_object);
|
|
37
32
|
} else {
|
|
@@ -57,7 +52,7 @@ export class CallPersonal extends CallBase {
|
|
|
57
52
|
const add = [];
|
|
58
53
|
for (let i = 0; i < this.data.mark.data.length; ++i) {
|
|
59
54
|
const v = this.data.mark.data[i];
|
|
60
|
-
const addr = await GetAccountOrMark_Address(v.
|
|
55
|
+
const addr = await GetAccountOrMark_Address(v.address);
|
|
61
56
|
if (addr) {
|
|
62
57
|
add.push({address:addr, tags:v.tags, name:v.name})
|
|
63
58
|
}
|
|
@@ -71,7 +66,7 @@ export class CallPersonal extends CallBase {
|
|
|
71
66
|
const remove = [];
|
|
72
67
|
for (let i = 0; i < this.data.mark.data.length; ++i) {
|
|
73
68
|
const v = this.data.mark.data[i];
|
|
74
|
-
const addr = await GetAccountOrMark_Address(v.
|
|
69
|
+
const addr = await GetAccountOrMark_Address(v.address);
|
|
75
70
|
if (addr) {
|
|
76
71
|
remove.push({address:addr, tags:v.tags})
|
|
77
72
|
}
|
|
@@ -81,8 +76,8 @@ export class CallPersonal extends CallBase {
|
|
|
81
76
|
})
|
|
82
77
|
break;
|
|
83
78
|
case 'removeall':
|
|
84
|
-
for (let i = 0; i < this.data.mark.
|
|
85
|
-
const v = this.data.mark.
|
|
79
|
+
for (let i = 0; i < this.data.mark.addresses.length; ++i) {
|
|
80
|
+
const v = this.data.mark.addresses[i];
|
|
86
81
|
const addr = await GetAccountOrMark_Address(v);
|
|
87
82
|
if (addr) {
|
|
88
83
|
obj?.removeall(addr)
|
package/src/call/repository.ts
CHANGED
|
@@ -1,17 +1,49 @@
|
|
|
1
1
|
import { TransactionBlock, PassportObject, Errors, ERROR, Permission, PermissionIndex,
|
|
2
|
-
PermissionIndexType, Repository,
|
|
3
|
-
|
|
2
|
+
PermissionIndexType, Repository, Repository_Policy_Mode, Repository_Value as Wowok_Repository_Value,
|
|
3
|
+
PermissionObject, uint2address, IsValidU256, ValueType, Repository_Policy, Repository_Value2,
|
|
4
4
|
} from 'wowok';
|
|
5
|
-
import { CallBase, CallResult, GetObjectExisted, GetObjectMain, GetObjectParam, ObjectMain, TypeNamedObjectWithPermission} from "./base.js";
|
|
5
|
+
import { AccountOrMark_Address, CallBase, CallResult, GetAccountOrMark_Address, GetObjectExisted, GetObjectMain, GetObjectParam, ObjectMain, ObjectsOp, 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
|
+
// Account name, or local mark name, or address, or u256 number|bigint(eg. time number) that can be converted to address.
|
|
11
|
+
export type AddressID = AccountOrMark_Address | number | bigint;
|
|
12
|
+
|
|
13
|
+
export const GetAddressID = async(key:AddressID) : Promise<string | undefined> =>{
|
|
14
|
+
if (typeof(key) === 'number' || typeof(key) === 'bigint') {
|
|
15
|
+
if (IsValidU256(key)) {
|
|
16
|
+
return uint2address(key);
|
|
17
|
+
}
|
|
18
|
+
} else {
|
|
19
|
+
return await GetAccountOrMark_Address(key)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface Repository_Value {
|
|
24
|
+
address: AddressID; // UID: address or objectid
|
|
25
|
+
bcsBytes: Uint8Array; // BCS contents. Notice that: First Byte be the Type by caller, or specify type with 'Repository_Policy_Data.value_type' field.
|
|
26
|
+
}
|
|
27
|
+
export interface Repository_Policy_Data {
|
|
28
|
+
key: string;
|
|
29
|
+
data: Repository_Value[];
|
|
30
|
+
value_type?: ValueType; // Specifies a data type prefix; If the data prefix is already included in the data byte stream, there is no need to specify it.
|
|
31
|
+
}
|
|
32
|
+
export interface Repository_Policy_Data2 {
|
|
33
|
+
address: AddressID;
|
|
34
|
+
data: Repository_Value2[];
|
|
35
|
+
value_type?: ValueType;
|
|
36
|
+
}
|
|
37
|
+
export interface Repository_Policy_Data_Remove {
|
|
38
|
+
key: string;
|
|
39
|
+
address: AddressID;
|
|
40
|
+
}
|
|
41
|
+
|
|
10
42
|
/// The execution priority is determined by the order in which the object attributes are arranged
|
|
11
43
|
export interface CallRepository_Data {
|
|
12
44
|
object?: ObjectMain;
|
|
13
45
|
description?: string;
|
|
14
|
-
reference?:
|
|
46
|
+
reference?: ObjectsOp;
|
|
15
47
|
mode?: Repository_Policy_Mode; // default: 'Relax' (POLICY_MODE_FREE)
|
|
16
48
|
policy?: {op:'add' | 'set'; data:Repository_Policy[]} | {op:'remove'; keys:string[]} | {op:'removeall'} | {op:'rename'; data:{old:string; new:string}[]};
|
|
17
49
|
data?: {op:'add', data: Repository_Policy_Data | Repository_Policy_Data2} | {op:'remove'; data: Repository_Policy_Data_Remove[]};
|
|
@@ -26,19 +58,24 @@ export class CallRepository extends CallBase {
|
|
|
26
58
|
this.data = data;
|
|
27
59
|
}
|
|
28
60
|
|
|
61
|
+
protected async prepare(): Promise<void> {
|
|
62
|
+
if (!this.object_address) {
|
|
63
|
+
this.object_address = (await LocalMark.Instance().get(GetObjectExisted(this.data?.object)))?.address;
|
|
64
|
+
if (this.object_address) {
|
|
65
|
+
await this.update_content('Repository', this.object_address);
|
|
66
|
+
if (!this.content) ERROR(Errors.InvalidParam, 'CallRepository_Data.data.object:' + this.object_address);
|
|
67
|
+
this.permission_address = (this.content as ObjectRepository).permission;
|
|
68
|
+
} else {
|
|
69
|
+
const n = GetObjectMain(this.data?.object) as TypeNamedObjectWithPermission;
|
|
70
|
+
this.permission_address = (await LocalMark.Instance().get_address(GetObjectExisted(n?.permission)));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
29
74
|
async call(account?:string) : Promise<CallResult> {
|
|
30
75
|
var checkOwner = false;
|
|
31
76
|
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
77
|
|
|
78
|
+
await this.prepare();
|
|
42
79
|
if (this.permission_address) {
|
|
43
80
|
if (!this.data?.object) {
|
|
44
81
|
perms.push(PermissionIndex.repository)
|
|
@@ -61,103 +98,109 @@ export class CallRepository extends CallBase {
|
|
|
61
98
|
}
|
|
62
99
|
|
|
63
100
|
protected async operate(txb:TransactionBlock, passport?:PassportObject, account?:string) {
|
|
64
|
-
let obj : Repository | undefined ; let
|
|
101
|
+
let obj : Repository | undefined ; let perm: Permission | undefined;
|
|
102
|
+
let permission : PermissionObject | undefined;
|
|
103
|
+
|
|
65
104
|
if (this.object_address) {
|
|
66
105
|
obj = Repository.From(txb, this.permission_address!, this.object_address);
|
|
106
|
+
permission = this.permission_address;
|
|
67
107
|
} else {
|
|
68
108
|
const n = GetObjectMain(this.data?.object) as TypeNamedObjectWithPermission;
|
|
69
|
-
|
|
70
|
-
|
|
109
|
+
permission = await LocalMark.Instance().get_address(GetObjectExisted(n?.permission));
|
|
110
|
+
if (!permission) {
|
|
111
|
+
perm = Permission.New(txb, GetObjectParam(n?.permission)?.description ?? '');
|
|
112
|
+
permission = perm.get_object();
|
|
71
113
|
}
|
|
72
114
|
|
|
73
|
-
obj = Repository.New(txb, permission
|
|
74
|
-
this.data.mode,
|
|
115
|
+
obj = Repository.New(txb, permission, this.data?.description??'',
|
|
116
|
+
this.data.mode, perm?undefined:passport);
|
|
75
117
|
}
|
|
76
118
|
|
|
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)
|
|
119
|
+
if (!obj) ERROR(Errors.InvalidParam, 'CallRepository_Data.object:' + this.object_address);
|
|
120
|
+
if (!permission) ERROR(Errors.InvalidParam, 'CallRepository_Data.permission:' + this.permission_address);
|
|
121
|
+
|
|
122
|
+
const pst = perm?undefined:passport;
|
|
123
|
+
if (this.data?.description !== undefined && this.object_address) {
|
|
124
|
+
obj?.set_description(this.data.description, pst);
|
|
125
|
+
}
|
|
126
|
+
if (this.data?.reference !== undefined) {
|
|
127
|
+
switch (this.data.reference.op) {
|
|
128
|
+
case 'set':
|
|
129
|
+
case 'add':
|
|
130
|
+
if (this.data.reference.op === 'set') obj?.remove_reference([], true, pst);
|
|
131
|
+
obj?.add_reference(await LocalMark.Instance().get_many_address2(this.data.reference.objects), pst);
|
|
132
|
+
break;
|
|
133
|
+
case 'remove':
|
|
134
|
+
obj?.remove_reference(await LocalMark.Instance().get_many_address2(this.data.reference.objects), false, pst);
|
|
135
|
+
break;
|
|
136
|
+
case 'removeall':
|
|
137
|
+
obj?.remove_reference([], true, pst);
|
|
138
|
+
break;
|
|
99
139
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
140
|
+
}
|
|
141
|
+
if (this.data?.mode !== undefined && this.object_address) { //@ priority??
|
|
142
|
+
obj?.set_policy_mode(this.data.mode, pst)
|
|
143
|
+
}
|
|
144
|
+
if (this.data?.policy !== undefined) {
|
|
145
|
+
switch(this.data.policy.op) {
|
|
146
|
+
case 'set':
|
|
147
|
+
obj?.remove_policies([], true, pst);
|
|
148
|
+
obj?.add_policies(this.data.policy.data, pst);
|
|
149
|
+
break;
|
|
150
|
+
case 'add':
|
|
151
|
+
obj?.add_policies(this.data.policy.data, pst);
|
|
152
|
+
break;
|
|
153
|
+
case 'remove':
|
|
154
|
+
obj?.remove_policies(this.data.policy.keys, false, pst);
|
|
155
|
+
break;
|
|
156
|
+
case 'removeall':
|
|
157
|
+
obj?.remove_policies([], true, pst);
|
|
158
|
+
break;
|
|
159
|
+
case 'rename':
|
|
160
|
+
this.data.policy.data.forEach((v) => {
|
|
161
|
+
obj?.rename_policy(v.old, v.new, pst);
|
|
162
|
+
})
|
|
163
|
+
break;
|
|
121
164
|
}
|
|
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);
|
|
165
|
+
}
|
|
166
|
+
if (this.data?.data !== undefined) {
|
|
167
|
+
switch(this.data.data.op) {
|
|
168
|
+
case 'add':
|
|
169
|
+
if ((this.data.data?.data as any)?.key !== undefined) {
|
|
170
|
+
const d = (this.data.data.data as Repository_Policy_Data).data;
|
|
171
|
+
const add: Wowok_Repository_Value[] = [];
|
|
172
|
+
for (let i=0; i<d.length; ++i) {
|
|
173
|
+
const addr = await GetAddressID(d[i].address);
|
|
138
174
|
if (addr) {
|
|
139
|
-
|
|
175
|
+
add.push({address:addr, bcsBytes:d[i].bcsBytes});
|
|
140
176
|
}
|
|
141
177
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
178
|
+
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});
|
|
179
|
+
} else if ((this.data.data?.data as any)?.address !== undefined) {
|
|
180
|
+
const d = this.data.data.data as Repository_Policy_Data2;
|
|
181
|
+
const addr = await GetAddressID(d.address);
|
|
182
|
+
if (addr) {
|
|
183
|
+
obj?.add_data2({address:addr, data:d.data, value_type:d.value_type})
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
break;
|
|
187
|
+
case 'remove':
|
|
188
|
+
for (let i=0; i<this.data.data.data.length; ++i) {
|
|
189
|
+
const addr = await GetAddressID(this.data.data.data[i].address);
|
|
190
|
+
if (addr) {
|
|
191
|
+
obj?.remove(addr, this.data.data.data[i].key);
|
|
149
192
|
}
|
|
150
|
-
|
|
151
|
-
|
|
193
|
+
}
|
|
194
|
+
break;
|
|
152
195
|
}
|
|
196
|
+
}
|
|
153
197
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
if (!this.object_address) {
|
|
159
|
-
await this.new_with_mark('Repository', txb, obj.launch(), GetObjectMain(this.data?.object), account);
|
|
160
|
-
}
|
|
198
|
+
if (perm) {
|
|
199
|
+
const n = GetObjectMain(this.data?.object) as TypeNamedObjectWithPermission;
|
|
200
|
+
await this.new_with_mark('Permission', txb, perm.launch(), GetObjectParam(n?.permission), account);
|
|
161
201
|
}
|
|
162
|
-
|
|
202
|
+
if (!this.object_address) {
|
|
203
|
+
await this.new_with_mark('Repository', txb, obj.launch(), GetObjectMain(this.data?.object), account);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
163
206
|
}
|