wowok_agent 1.2.38 → 1.2.41
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 -1
- package/dist/call/arbitration.d.ts.map +1 -1
- package/dist/call/arbitration.js +76 -50
- package/dist/call/arbitration.js.map +1 -1
- package/dist/call/base.d.ts +3 -1
- package/dist/call/base.d.ts.map +1 -1
- package/dist/call/base.js +24 -16
- package/dist/call/base.js.map +1 -1
- package/dist/call/call.d.ts +18 -18
- package/dist/call/call.d.ts.map +1 -1
- package/dist/call/call.js +12 -12
- package/dist/call/call.js.map +1 -1
- package/dist/call/demand.d.ts +3 -1
- package/dist/call/demand.d.ts.map +1 -1
- package/dist/call/demand.js +55 -28
- package/dist/call/demand.js.map +1 -1
- package/dist/call/guard.d.ts.map +1 -1
- package/dist/call/guard.js +29 -18
- package/dist/call/guard.js.map +1 -1
- package/dist/call/machine.d.ts +1 -1
- package/dist/call/machine.d.ts.map +1 -1
- package/dist/call/machine.js +82 -38
- package/dist/call/machine.js.map +1 -1
- package/dist/call/object_permission.d.ts +1 -0
- package/dist/call/object_permission.d.ts.map +1 -1
- package/dist/call/object_permission.js +12 -9
- package/dist/call/object_permission.js.map +1 -1
- package/dist/call/permission.d.ts +1 -0
- package/dist/call/permission.d.ts.map +1 -1
- package/dist/call/permission.js +48 -18
- package/dist/call/permission.js.map +1 -1
- package/dist/call/personal.d.ts +1 -1
- package/dist/call/personal.d.ts.map +1 -1
- package/dist/call/personal.js +40 -13
- package/dist/call/personal.js.map +1 -1
- package/dist/call/repository.d.ts.map +1 -1
- package/dist/call/repository.js +24 -14
- package/dist/call/repository.js.map +1 -1
- package/dist/call/service.d.ts +1 -1
- package/dist/call/service.d.ts.map +1 -1
- package/dist/call/service.js +149 -71
- package/dist/call/service.js.map +1 -1
- package/dist/call/treasury.d.ts +1 -1
- package/dist/call/treasury.d.ts.map +1 -1
- package/dist/call/treasury.js +65 -49
- 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 +9 -0
- package/dist/common.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/local/account.d.ts +26 -12
- package/dist/local/account.d.ts.map +1 -1
- package/dist/local/account.js +199 -93
- package/dist/local/account.js.map +1 -1
- package/dist/local/index.d.ts +44 -23
- package/dist/local/index.d.ts.map +1 -1
- package/dist/local/index.js +57 -50
- package/dist/local/index.js.map +1 -1
- package/dist/local/local.d.ts +4 -2
- package/dist/local/local.d.ts.map +1 -1
- package/dist/local/local.js +35 -27
- package/dist/local/local.js.map +1 -1
- package/dist/query/objects.d.ts.map +1 -1
- package/dist/query/objects.js +15 -7
- package/dist/query/objects.js.map +1 -1
- package/package.json +2 -2
- package/src/call/arbitration.ts +87 -54
- package/src/call/base.ts +28 -19
- package/src/call/call.ts +31 -31
- package/src/call/demand.ts +62 -30
- package/src/call/guard.ts +25 -16
- package/src/call/machine.ts +89 -42
- package/src/call/object_permission.ts +12 -8
- package/src/call/permission.ts +45 -18
- package/src/call/personal.ts +39 -13
- package/src/call/repository.ts +27 -13
- package/src/call/service.ts +152 -73
- package/src/call/treasury.ts +70 -50
- package/src/common.ts +9 -0
- package/src/index.ts +1 -0
- package/src/local/account.ts +212 -92
- package/src/local/index.ts +75 -68
- package/src/local/local.ts +44 -30
- package/src/query/objects.ts +14 -6
- package/tsconfig.tsbuildinfo +1 -1
package/src/call/demand.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { PassportObject, IsValidAddress, Errors, ERROR, Permission, PermissionIn
|
|
|
4
4
|
import { query_objects, ObjectDemand } from '../query/objects.js';
|
|
5
5
|
import { CallBase, CallResult, Namedbject } from "./base.js";
|
|
6
6
|
import { Account } from '../local/account.js';
|
|
7
|
+
import { LocalMark } from '../local/local.js';
|
|
7
8
|
|
|
8
9
|
/// The execution priority is determined by the order in which the object attributes are arranged
|
|
9
10
|
export interface CallDemand_Data {
|
|
@@ -13,27 +14,41 @@ export interface CallDemand_Data {
|
|
|
13
14
|
description?: string;
|
|
14
15
|
time_expire?: {op: 'duration'; minutes:number} | {op:'time'; time:number};
|
|
15
16
|
bounty?: {op:'add'; object:{address:string}|{balance:string|number}} | {op:'reward'; service:string} | {op:'refund'} ;
|
|
16
|
-
present?: {service: string | number; recommend_words:string; service_pay_type:string, guard?:string
|
|
17
|
+
present?: {service: string | number; recommend_words:string; service_pay_type:string, guard?:string}; // guard is the present guard of Demand
|
|
17
18
|
guard?: {address:string; service_id_in_guard?:number};
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
export class CallDemand extends CallBase {
|
|
21
|
-
data: CallDemand_Data;
|
|
22
|
+
data: CallDemand_Data;
|
|
23
|
+
content: ObjectDemand | undefined = undefined;
|
|
24
|
+
|
|
22
25
|
constructor(data: CallDemand_Data) {
|
|
23
26
|
super();
|
|
24
27
|
this.data = data;
|
|
25
28
|
}
|
|
26
29
|
async call(account?:string) : Promise<CallResult> {
|
|
27
|
-
if (!this.data?.type_parameter || !IsValidArgType(this.data.type_parameter)) {
|
|
28
|
-
ERROR(Errors.IsValidArgType, 'demand.type_parameter')
|
|
29
|
-
}
|
|
30
|
-
|
|
31
30
|
var checkOwner = false; const guards : string[] = [];
|
|
32
31
|
const perms : PermissionIndexType[] = [];
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
var [permission_address, object_address] =
|
|
33
|
+
await LocalMark.Instance().get_many_address(
|
|
34
|
+
[(this.data?.permission as any)?.address,
|
|
35
|
+
(this.data?.object as any)?.address]);
|
|
36
|
+
|
|
37
|
+
if (object_address) {
|
|
38
|
+
if (!this.data.type_parameter || !permission_address) {
|
|
39
|
+
await this.update_content(object_address, 'Demand');
|
|
40
|
+
if (this.content) {
|
|
41
|
+
permission_address = (this.content as ObjectDemand).permission;
|
|
42
|
+
this.data.type_parameter = this.content.type_raw!;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
if (!this.data?.type_parameter || !IsValidArgType(this.data.type_parameter)) {
|
|
47
|
+
ERROR(Errors.IsValidArgType, 'CallDemand_Data.data.type_parameter')
|
|
48
|
+
}
|
|
49
|
+
}
|
|
35
50
|
|
|
36
|
-
if (permission_address
|
|
51
|
+
if (permission_address) {
|
|
37
52
|
if (!this.data?.object) {
|
|
38
53
|
perms.push(PermissionIndex.demand)
|
|
39
54
|
}
|
|
@@ -53,21 +68,23 @@ export class CallDemand extends CallBase {
|
|
|
53
68
|
perms.push(PermissionIndex.demand_refund)
|
|
54
69
|
}
|
|
55
70
|
if (this.data?.present?.guard !== undefined) {
|
|
56
|
-
if (
|
|
57
|
-
|
|
71
|
+
if (this.data.present.guard) {
|
|
72
|
+
const guard = await LocalMark.Instance().get_address(this.data.present.guard)
|
|
73
|
+
if (guard) {
|
|
74
|
+
guards.push(guard)
|
|
75
|
+
}
|
|
58
76
|
} else {
|
|
59
77
|
if (!object_address) { // new
|
|
60
|
-
|
|
61
|
-
|
|
78
|
+
const guard = await LocalMark.Instance().get_address(this.data?.guard?.address);
|
|
79
|
+
if (guard) {
|
|
80
|
+
guards.push(guard)
|
|
62
81
|
}
|
|
63
82
|
} else {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
}
|
|
83
|
+
await this.update_content(object_address, 'Demand');
|
|
84
|
+
|
|
85
|
+
if ((this.content as ObjectDemand)?.guard?.object) {
|
|
86
|
+
guards.push((this.content as ObjectDemand).guard?.object!)
|
|
87
|
+
}
|
|
71
88
|
}
|
|
72
89
|
}
|
|
73
90
|
}
|
|
@@ -77,11 +94,14 @@ export class CallDemand extends CallBase {
|
|
|
77
94
|
}
|
|
78
95
|
protected async operate(txb:TransactionBlock, passport?:PassportObject, account?:string) {
|
|
79
96
|
let obj : Demand | undefined ; let permission: any;
|
|
80
|
-
|
|
81
|
-
|
|
97
|
+
var [permission_address, object_address] = this?.content ?
|
|
98
|
+
[(this.content as ObjectDemand).permission, this.content.object] :
|
|
99
|
+
await LocalMark.Instance().get_many_address(
|
|
100
|
+
[(this.data?.permission as any)?.address,
|
|
101
|
+
(this.data?.object as any)?.address]);
|
|
82
102
|
|
|
83
103
|
if (!object_address) {
|
|
84
|
-
if (!permission_address
|
|
104
|
+
if (!permission_address) {
|
|
85
105
|
const d = (this.data?.permission as any)?.description ?? '';
|
|
86
106
|
permission = Permission.New(txb, d);
|
|
87
107
|
}
|
|
@@ -95,10 +115,10 @@ export class CallDemand extends CallBase {
|
|
|
95
115
|
permission ? permission.get_object(): permission_address, this.data?.description??'', permission?undefined:passport)
|
|
96
116
|
}
|
|
97
117
|
} else {
|
|
98
|
-
if (
|
|
118
|
+
if (this.data.type_parameter && permission_address) {
|
|
99
119
|
obj = Demand.From(txb, this.data.type_parameter, permission_address, object_address)
|
|
100
120
|
} else {
|
|
101
|
-
ERROR(Errors.InvalidParam, '
|
|
121
|
+
ERROR(Errors.InvalidParam, 'CallDemand_Data.data.type_parameter or permission')
|
|
102
122
|
}
|
|
103
123
|
}
|
|
104
124
|
|
|
@@ -113,27 +133,39 @@ export class CallDemand extends CallBase {
|
|
|
113
133
|
}
|
|
114
134
|
if (this.data?.bounty !== undefined) {
|
|
115
135
|
if (this.data.bounty.op === 'add') {
|
|
116
|
-
|
|
136
|
+
const bounty = await LocalMark.Instance().get_address((this.data.bounty.object as any)?.address)
|
|
137
|
+
if (bounty) {
|
|
117
138
|
obj.deposit((this.data.bounty.object as any)?.address)
|
|
118
139
|
} else if ((this.data.bounty.object as any)?.balance !== undefined){
|
|
119
140
|
if (!IsValidCoinType(this.data.type_parameter)) {
|
|
120
|
-
ERROR(Errors.IsValidCoinType, '
|
|
141
|
+
ERROR(Errors.IsValidCoinType, 'CallDemand_Data.data.type_parameter')
|
|
121
142
|
}
|
|
122
143
|
const r = await Account.Instance().get_coin_object(txb, (this.data.bounty.object as any)?.balance, account, this.data.type_parameter);
|
|
123
144
|
if (r) obj.deposit(r)
|
|
124
145
|
}
|
|
125
146
|
} else if (this.data.bounty.op === 'reward') {
|
|
126
|
-
|
|
147
|
+
const service = await localStorage.Instance().get_address(this.data.bounty.service);
|
|
148
|
+
if (!service) ERROR(Errors.InvalidParam, 'CallDemand_Data.data.bounty.service');
|
|
149
|
+
obj?.yes(service, pst);
|
|
127
150
|
} else if (this.data.bounty.op === 'refund') {
|
|
128
151
|
obj?.refund(pst);
|
|
129
152
|
}
|
|
130
153
|
}
|
|
131
154
|
if (this.data?.present !== undefined) {
|
|
132
155
|
//@ demand guard and its pst, if set
|
|
133
|
-
|
|
156
|
+
const service = typeof(this.data.present.service) === 'string' ? (await LocalMark.Instance().get_address(this.data.present.service)): this.data.present.service;
|
|
157
|
+
if (service === undefined) {
|
|
158
|
+
ERROR(Errors.InvalidParam, 'CallDemand_Data.data.present.service')
|
|
159
|
+
}
|
|
160
|
+
obj?.present(typeof(this.data.present.service) === 'string' ? service : this.data.present.service, this.data.present.service_pay_type, this.data.present.recommend_words, pst);
|
|
134
161
|
}
|
|
162
|
+
|
|
135
163
|
if (this.data?.guard !== undefined) {
|
|
136
|
-
|
|
164
|
+
const guard = await LocalMark.Instance().get_address(this.data?.guard.address);
|
|
165
|
+
if (!guard) {
|
|
166
|
+
ERROR(Errors.InvalidParam, 'CallDemand_Data.data.guard.address')
|
|
167
|
+
}
|
|
168
|
+
obj?.set_guard(guard, this.data.guard?.service_id_in_guard ?? undefined, pst);
|
|
137
169
|
}
|
|
138
170
|
if (permission) {
|
|
139
171
|
await this.new_with_mark('Permission', txb, permission.launch(), (this.data?.permission as any)?.namedNew, account);
|
package/src/call/guard.ts
CHANGED
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
import { Bcs, ContextType, ERROR, Errors, IsValidU8, OperatorType, ValueType, GUARD_QUERIES, IsValidAddress,
|
|
7
7
|
concatenate, TransactionBlock, Protocol, FnCallType, hasDuplicates, insertAtHead,
|
|
8
|
-
IsValidDesription, PassportObject, IsValidGuardIdentifier, GuardQuery
|
|
8
|
+
IsValidDesription, PassportObject, IsValidGuardIdentifier, GuardQuery,
|
|
9
9
|
} from "wowok";
|
|
10
10
|
import { CallBase, CallResult, Namedbject } from "./base.js";
|
|
11
|
+
import { LocalMark } from "../local/local.js";
|
|
11
12
|
|
|
12
13
|
export interface GuardConst {
|
|
13
14
|
identifier: number; // 1-255, the same identifier to represent the same data in different nodes
|
|
@@ -71,22 +72,30 @@ export class CallGuard extends CallBase {
|
|
|
71
72
|
target: Protocol.Instance().guardFn('new') as FnCallType,
|
|
72
73
|
arguments: [txb.pure.string(this.data.description ?? ''), txb.pure.vector('u8', [].slice.call(bytes.reverse()))],
|
|
73
74
|
});
|
|
74
|
-
this.data
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
75
|
+
if (this.data.table) {
|
|
76
|
+
for (let i = 0; i < this.data?.table?.length; ++ i) {
|
|
77
|
+
const v = this.data.table[i];
|
|
78
|
+
if (v.bWitness) {
|
|
79
|
+
const n = new Uint8Array(1); n.set([v.value_type], 0);
|
|
80
|
+
txb.moveCall({
|
|
81
|
+
target:Protocol.Instance().guardFn("constant_add") as FnCallType,
|
|
82
|
+
arguments:[txb.object(obj), txb.pure.u8(v.identifier), txb.pure.bool(true), txb.pure.vector('u8', [].slice.call(n)), txb.pure.bool(false)]
|
|
83
|
+
})
|
|
84
|
+
} else {
|
|
85
|
+
if (v.value_type === ValueType.TYPE_ADDRESS) {
|
|
86
|
+
v.value = await LocalMark.Instance().get_address(v.value);
|
|
87
|
+
if (!v.value) { ERROR(Errors.InvalidParam, `CallGuard_Data.data.table address`)}
|
|
88
|
+
};
|
|
89
|
+
const tmp = Uint8Array.from(Bcs.getInstance().ser(v.value_type, v.value));
|
|
90
|
+
const n = insertAtHead(tmp, v.value_type);
|
|
91
|
+
txb.moveCall({
|
|
92
|
+
target:Protocol.Instance().guardFn("constant_add") as FnCallType,
|
|
93
|
+
arguments:[txb.object(obj), txb.pure.u8(v.identifier), txb.pure.bool(false), txb.pure.vector('u8', [].slice.call(n)), txb.pure.bool(false)]
|
|
94
|
+
})
|
|
95
|
+
}
|
|
88
96
|
}
|
|
89
|
-
}
|
|
97
|
+
}
|
|
98
|
+
|
|
90
99
|
const addr = txb.moveCall({
|
|
91
100
|
target:Protocol.Instance().guardFn("create") as FnCallType,
|
|
92
101
|
arguments:[txb.object(obj)]
|
package/src/call/machine.ts
CHANGED
|
@@ -4,6 +4,8 @@ import { PassportObject, IsValidAddress, Errors, ERROR, Permission, PermissionIn
|
|
|
4
4
|
} from 'wowok';
|
|
5
5
|
import { CallBase, CallResult, Namedbject } from "./base.js";
|
|
6
6
|
import { Account } from '../local/account.js';
|
|
7
|
+
import { ObjectMachine } from '../query/objects.js';
|
|
8
|
+
import { LocalMark } from '../local/local.js';
|
|
7
9
|
|
|
8
10
|
/// The execution priority is determined by the order in which the object attributes are arranged
|
|
9
11
|
export interface CallMachine_Data {
|
|
@@ -24,7 +26,7 @@ export interface CallMachine_Data {
|
|
|
24
26
|
progress_parent?: {progress?:string, parent?:ParentProgress};
|
|
25
27
|
progress_task?: {progress?:string; task:string};
|
|
26
28
|
progress_hold?: {progress?:string; operation:ProgressNext; bHold:boolean; adminUnhold?:boolean};
|
|
27
|
-
progress_next?: {progress:string; operation:ProgressNext; deliverable:Deliverable; guard?:string
|
|
29
|
+
progress_next?: {progress:string; operation:ProgressNext; deliverable:Deliverable; guard?:string};
|
|
28
30
|
bPaused?: boolean;
|
|
29
31
|
clone_new?: {namedNew?: Namedbject/*, description?:string*/};
|
|
30
32
|
}
|
|
@@ -37,10 +39,21 @@ export class CallMachine extends CallBase { //@ todo self-owned node operate
|
|
|
37
39
|
async call(account?:string) : Promise<CallResult> {
|
|
38
40
|
var checkOwner = false; const guards : string[] = [];
|
|
39
41
|
const perms : PermissionIndexType[] = [];
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
var [permission_address, object_address] =
|
|
43
|
+
await LocalMark.Instance().get_many_address(
|
|
44
|
+
[(this.data?.permission as any)?.address,
|
|
45
|
+
(this.data?.object as any)?.address]);
|
|
42
46
|
|
|
43
|
-
if (
|
|
47
|
+
if (object_address) {
|
|
48
|
+
if (!permission_address) {
|
|
49
|
+
await this.update_content(object_address, 'Machine');
|
|
50
|
+
if (this.content) {
|
|
51
|
+
permission_address = (this.content as ObjectMachine).permission;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (permission_address) {
|
|
44
57
|
if (!this.data?.object) {
|
|
45
58
|
perms.push(PermissionIndex.machine)
|
|
46
59
|
}
|
|
@@ -82,15 +95,21 @@ export class CallMachine extends CallBase { //@ todo self-owned node operate
|
|
|
82
95
|
if (this.data?.bPaused !== undefined) {
|
|
83
96
|
perms.push(PermissionIndex.machine_pause)
|
|
84
97
|
}
|
|
85
|
-
if (this.data?.progress_next
|
|
86
|
-
if (
|
|
87
|
-
|
|
88
|
-
} else if (this.data?.object && IsValidAddress(object_address)) { // fetch guard
|
|
89
|
-
const guard = await Progress.QueryForwardGuard(this.data?.progress_next.progress, object_address,
|
|
90
|
-
await Account.Instance().default() ?? '0xe386bb9e01b3528b75f3751ad8a1e418b207ad979fea364087deef5250a73d3f',
|
|
91
|
-
this.data.progress_next.operation.next_node_name, this.data.progress_next.operation.forward);
|
|
98
|
+
if (this.data?.progress_next !== undefined) {
|
|
99
|
+
if (this.data?.progress_next?.guard) {
|
|
100
|
+
const guard = await LocalMark.Instance().get_address(this.data?.progress_next?.guard);
|
|
92
101
|
if (guard) {
|
|
93
|
-
guards.push(guard)
|
|
102
|
+
guards.push(guard);
|
|
103
|
+
}
|
|
104
|
+
} else if (object_address) { // fetch guard
|
|
105
|
+
const p = await LocalMark.Instance().get_address(this.data?.progress_next.progress);
|
|
106
|
+
if (p) {
|
|
107
|
+
const guard = await Progress.QueryForwardGuard(this.data?.progress_next.progress, object_address,
|
|
108
|
+
(await Account.Instance().default())?.address ?? '0xe386bb9e01b3528b75f3751ad8a1e418b207ad979fea364087deef5250a73d3f',
|
|
109
|
+
this.data.progress_next.operation.next_node_name, this.data.progress_next.operation.forward);
|
|
110
|
+
if (guard) {
|
|
111
|
+
guards.push(guard);
|
|
112
|
+
}
|
|
94
113
|
}
|
|
95
114
|
}
|
|
96
115
|
}
|
|
@@ -102,20 +121,23 @@ export class CallMachine extends CallBase { //@ todo self-owned node operate
|
|
|
102
121
|
|
|
103
122
|
protected async operate(txb:TransactionBlock, passport?:PassportObject, account?:string) {
|
|
104
123
|
let obj : Machine | undefined ; let permission: any;
|
|
105
|
-
|
|
106
|
-
|
|
124
|
+
var [permission_address, object_address] = this?.content ?
|
|
125
|
+
[(this.content as ObjectMachine).permission, this.content.object] :
|
|
126
|
+
await LocalMark.Instance().get_many_address(
|
|
127
|
+
[(this.data?.permission as any)?.address,
|
|
128
|
+
(this.data?.object as any)?.address]);
|
|
107
129
|
|
|
108
130
|
if (!object_address) {
|
|
109
|
-
if (!permission_address
|
|
131
|
+
if (!permission_address) {
|
|
110
132
|
const d = (this.data?.permission as any)?.description ?? '';
|
|
111
133
|
permission = Permission.New(txb, d);
|
|
112
134
|
}
|
|
113
135
|
obj = Machine.New(txb, permission ? permission.get_object() : permission_address, this.data?.description??'', this.data?.endpoint ?? '', permission?undefined:passport);
|
|
114
136
|
} else {
|
|
115
|
-
if (
|
|
137
|
+
if (permission_address) {
|
|
116
138
|
obj = Machine.From(txb, permission_address, object_address)
|
|
117
139
|
} else {
|
|
118
|
-
ERROR(Errors.InvalidParam, '
|
|
140
|
+
ERROR(Errors.InvalidParam, 'CallMachine_Data.data.permission')
|
|
119
141
|
}
|
|
120
142
|
}
|
|
121
143
|
|
|
@@ -133,18 +155,22 @@ export class CallMachine extends CallBase { //@ todo self-owned node operate
|
|
|
133
155
|
if (this.data?.consensus_repository !== undefined) {
|
|
134
156
|
switch (this.data.consensus_repository.op) {
|
|
135
157
|
case 'add':
|
|
136
|
-
|
|
158
|
+
case 'set':
|
|
159
|
+
if (this.data.consensus_repository.op === 'set') {
|
|
160
|
+
obj?.remove_repository([], true, pst);
|
|
161
|
+
}
|
|
162
|
+
var reps = await LocalMark.Instance().get_many_address2(this.data.consensus_repository.repositories);
|
|
163
|
+
reps.forEach(v=>obj?.add_repository(v, pst)) ;
|
|
137
164
|
break;
|
|
138
165
|
case 'remove':
|
|
139
|
-
|
|
166
|
+
var reps = await LocalMark.Instance().get_many_address2(this.data.consensus_repository.repositories);
|
|
167
|
+
if (reps.length > 0) {
|
|
168
|
+
obj?.remove_repository(reps, false, pst);
|
|
169
|
+
}
|
|
140
170
|
break;
|
|
141
171
|
case 'removeall':
|
|
142
172
|
obj?.remove_repository([], true, pst);
|
|
143
173
|
break;
|
|
144
|
-
case 'set':
|
|
145
|
-
obj?.remove_repository([], true, pst);
|
|
146
|
-
this.data.consensus_repository.repositories.forEach(v=>obj?.add_repository(v, pst)) ;
|
|
147
|
-
break;
|
|
148
174
|
}
|
|
149
175
|
}
|
|
150
176
|
if (this.data?.nodes !== undefined) {
|
|
@@ -177,55 +203,76 @@ export class CallMachine extends CallBase { //@ todo self-owned node operate
|
|
|
177
203
|
}
|
|
178
204
|
var new_progress : Progress | undefined;
|
|
179
205
|
if (this.data?.progress_new !== undefined) {
|
|
180
|
-
|
|
206
|
+
const task = await LocalMark.Instance().get_address(this.data?.progress_new.task_address);
|
|
207
|
+
new_progress = Progress?.New(txb, obj?.get_object(), perm, task, pst);
|
|
181
208
|
}
|
|
182
209
|
if (this.data?.progress_context_repository !== undefined) {
|
|
183
|
-
const p = this.data?.progress_context_repository.progress
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
210
|
+
const p = this.data?.progress_context_repository.progress
|
|
211
|
+
? await LocalMark.Instance().get_address(this.data?.progress_context_repository.progress)
|
|
212
|
+
: new_progress?.get_object();
|
|
213
|
+
if (!p) ERROR(Errors.InvalidParam, 'CallMachine_Data.data.progress_context_repository.progress');
|
|
214
|
+
const rep = await LocalMark.Instance().get_address(this.data?.progress_context_repository.repository);
|
|
215
|
+
Progress.From(txb, obj?.get_object(), perm, p!).set_context_repository(rep, pst)
|
|
187
216
|
}
|
|
188
217
|
if (this.data?.progress_namedOperator !== undefined) {
|
|
189
|
-
const p = this.data?.progress_namedOperator.progress
|
|
190
|
-
|
|
218
|
+
const p = this.data?.progress_namedOperator.progress
|
|
219
|
+
? await LocalMark.Instance().get_address(this.data?.progress_namedOperator.progress)
|
|
220
|
+
: new_progress?.get_object();
|
|
221
|
+
if (!p) ERROR(Errors.InvalidParam, 'CallMachine_Data.data.progress_namedOperator.progress');
|
|
191
222
|
|
|
192
223
|
let pp = Progress.From(txb, obj?.get_object(), perm, p!);
|
|
193
224
|
this.data.progress_namedOperator.data.forEach(v => pp.set_namedOperator(v.name, v.operators, pst));
|
|
194
225
|
}
|
|
195
226
|
if (this.data?.progress_parent !== undefined) {
|
|
196
|
-
const p = this.data?.progress_parent.progress
|
|
197
|
-
|
|
227
|
+
const p = this.data?.progress_parent.progress
|
|
228
|
+
? await LocalMark.Instance().get_address(this.data?.progress_parent.progress)
|
|
229
|
+
: new_progress?.get_object();
|
|
230
|
+
if (!p) ERROR(Errors.InvalidParam, 'CallMachine_Data.data.progress_parent.progress');
|
|
198
231
|
|
|
199
232
|
if (this.data.progress_parent.parent) {
|
|
200
|
-
|
|
233
|
+
const parent = await LocalMark.Instance().get_address(this.data.progress_parent.parent.parent_id);
|
|
234
|
+
if (parent) {
|
|
235
|
+
this.data.progress_parent.parent.parent_id = parent;
|
|
236
|
+
Progress.From(txb, obj?.get_object(), perm, p!).parent(this.data.progress_parent.parent);
|
|
237
|
+
}
|
|
201
238
|
} else {
|
|
202
239
|
Progress.From(txb, obj?.get_object(), perm, p!).parent_none();
|
|
203
240
|
}
|
|
204
241
|
}
|
|
205
242
|
if (this.data?.progress_task !== undefined) {
|
|
206
|
-
const p = this.data?.progress_task.progress
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
243
|
+
const p = this.data?.progress_task.progress
|
|
244
|
+
? await LocalMark.Instance().get_address(this.data?.progress_task.progress)
|
|
245
|
+
: new_progress?.get_object();
|
|
246
|
+
if (!p) ERROR(Errors.InvalidParam, 'CallMachine_Data.data.progress_task.progress');
|
|
247
|
+
const task = await LocalMark.Instance().get_address(this.data.progress_task.task);
|
|
248
|
+
if (task) Progress.From(txb, obj?.get_object(), perm, p!).bind_task(task, pst);
|
|
210
249
|
}
|
|
211
250
|
if (this.data?.progress_hold !== undefined) {
|
|
212
|
-
const p = this.data?.progress_hold.progress
|
|
213
|
-
|
|
251
|
+
const p = this.data?.progress_hold.progress
|
|
252
|
+
? await LocalMark.Instance().get_address(this.data?.progress_hold.progress)
|
|
253
|
+
: new_progress?.get_object();
|
|
254
|
+
if (!p) ERROR(Errors.InvalidParam, 'CallMachine_Data.data.progress_hold.progress');
|
|
214
255
|
|
|
215
256
|
if (this.data?.progress_hold.adminUnhold) {
|
|
216
257
|
Progress.From(txb, obj?.get_object(), perm, p!).unhold(this.data.progress_hold.operation, pst)
|
|
217
258
|
} else {
|
|
218
259
|
Progress.From(txb, obj?.get_object(), perm, p!).hold(this.data.progress_hold.operation, this.data.progress_hold.bHold)
|
|
219
260
|
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
if (this.data?.progress_next !== undefined) {
|
|
264
|
+
const p = this.data?.progress_next.progress
|
|
265
|
+
? await LocalMark.Instance().get_address(this.data?.progress_next.progress)
|
|
266
|
+
: new_progress?.get_object();
|
|
267
|
+
if (!p) ERROR(Errors.InvalidParam, 'CallMachine_Data.data.progress_next.progress');
|
|
268
|
+
Progress.From(txb, obj?.get_object(), perm, p!).next(this.data.progress_next.operation, this.data.progress_next.deliverable, pst)
|
|
220
269
|
}
|
|
270
|
+
|
|
221
271
|
const addr = new_progress?.launch();
|
|
222
272
|
if (addr) {
|
|
223
273
|
await this.new_with_mark('Progress', txb, addr, this.data?.progress_new?.namedNew, account);
|
|
224
274
|
}
|
|
225
275
|
|
|
226
|
-
if (this.data?.progress_next !== undefined) {
|
|
227
|
-
Progress.From(txb, obj?.get_object(), perm, this.data?.progress_next.progress).next(this.data.progress_next.operation, this.data.progress_next.deliverable, pst)
|
|
228
|
-
}
|
|
229
276
|
if (this.data?.bPaused !== undefined) {
|
|
230
277
|
obj?.pause(this.data.bPaused, pst)
|
|
231
278
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CallBase, CallResult } from "./base.js";
|
|
2
2
|
import { TransactionBlock, PassportObject, IsValidAddress, Errors, ERROR, Demand, Machine, Service, Treasury, Arbitration, Repository} from 'wowok';
|
|
3
3
|
import { ObjectArbitration, ObjectDemand, ObjectMachine, ObjectRepository, ObjectService, ObjectTreasury, query_objects } from "../query/objects.js";
|
|
4
|
+
import { LocalMark } from "../local/local.js";
|
|
4
5
|
|
|
5
6
|
export interface CallObjectPermission_Data {
|
|
6
7
|
objects: string[];
|
|
@@ -9,14 +10,17 @@ export interface CallObjectPermission_Data {
|
|
|
9
10
|
|
|
10
11
|
export class CallObjectPermission extends CallBase {
|
|
11
12
|
data: CallObjectPermission_Data;
|
|
13
|
+
new_perm: string | undefined = undefined;
|
|
14
|
+
|
|
12
15
|
constructor(data:CallObjectPermission_Data) {
|
|
13
16
|
super();
|
|
14
17
|
this.data = data;
|
|
15
18
|
}
|
|
16
19
|
|
|
17
20
|
async call(account?:string) : Promise<CallResult> {
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
this.new_perm = await LocalMark.Instance().get_address(this.data.new_permission);
|
|
22
|
+
if (!this.new_perm) {
|
|
23
|
+
ERROR(Errors.InvalidParam, 'CallObjectPermission_Data.new_permission:' + this.data.new_permission)
|
|
20
24
|
}
|
|
21
25
|
|
|
22
26
|
if (this.data?.objects.length > 0) {
|
|
@@ -29,27 +33,27 @@ export class CallObjectPermission extends CallBase {
|
|
|
29
33
|
switch(v.type) {
|
|
30
34
|
case 'Demand':
|
|
31
35
|
const demand = v as ObjectDemand;
|
|
32
|
-
Demand.From(txb, Demand.parseObjectType(demand.type_raw), demand.permission, demand.object).change_permission(this.
|
|
36
|
+
Demand.From(txb, Demand.parseObjectType(demand.type_raw), demand.permission, demand.object).change_permission(this.new_perm!);
|
|
33
37
|
break;
|
|
34
38
|
case 'Machine':
|
|
35
39
|
const machine = v as ObjectMachine;
|
|
36
|
-
Machine.From(txb, machine.permission, machine.object).change_permission(this.
|
|
40
|
+
Machine.From(txb, machine.permission, machine.object).change_permission(this.new_perm!);
|
|
37
41
|
break;
|
|
38
42
|
case 'Service':
|
|
39
43
|
const service = v as ObjectService;
|
|
40
|
-
Service.From(txb, Service.parseObjectType(service.type_raw), service.permission, service.object).change_permission(this.
|
|
44
|
+
Service.From(txb, Service.parseObjectType(service.type_raw), service.permission, service.object).change_permission(this.new_perm!);
|
|
41
45
|
break;
|
|
42
46
|
case 'Treasury':
|
|
43
47
|
const treasury = v as ObjectTreasury;
|
|
44
|
-
Treasury.From(txb, Treasury.parseObjectType(treasury.type_raw), treasury.permission, treasury.object).change_permission(this.
|
|
48
|
+
Treasury.From(txb, Treasury.parseObjectType(treasury.type_raw), treasury.permission, treasury.object).change_permission(this.new_perm!);
|
|
45
49
|
break;
|
|
46
50
|
case 'Arbitration':
|
|
47
51
|
const arbitraion = v as ObjectArbitration;
|
|
48
|
-
Arbitration.From(txb, Arbitration.parseObjectType(arbitraion.type_raw), arbitraion.permission, arbitraion.object).change_permission(this.
|
|
52
|
+
Arbitration.From(txb, Arbitration.parseObjectType(arbitraion.type_raw), arbitraion.permission, arbitraion.object).change_permission(this.new_perm!);
|
|
49
53
|
break;
|
|
50
54
|
case 'Repository':
|
|
51
55
|
const repository = v as ObjectRepository;
|
|
52
|
-
Repository.From(txb, repository.permission, repository.object).change_permission(this.
|
|
56
|
+
Repository.From(txb, repository.permission, repository.object).change_permission(this.new_perm!);
|
|
53
57
|
break;
|
|
54
58
|
}
|
|
55
59
|
})
|