wowok_agent 1.3.49 → 1.3.51
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.map +1 -1
- package/dist/call/arbitration.js +34 -34
- package/dist/call/arbitration.js.map +1 -1
- package/dist/call/base.d.ts +2 -2
- package/dist/call/base.d.ts.map +1 -1
- package/dist/call/base.js +5 -5
- package/dist/call/base.js.map +1 -1
- package/dist/call/demand.js +26 -26
- package/dist/call/demand.js.map +1 -1
- package/dist/call/machine.js +36 -36
- package/dist/call/machine.js.map +1 -1
- package/dist/call/permission.js +8 -8
- package/dist/call/permission.js.map +1 -1
- package/dist/call/personal.js +2 -2
- package/dist/call/personal.js.map +1 -1
- package/dist/call/repository.js +21 -21
- package/dist/call/repository.js.map +1 -1
- package/dist/call/service.d.ts +6 -1
- package/dist/call/service.d.ts.map +1 -1
- package/dist/call/service.js +53 -53
- package/dist/call/service.js.map +1 -1
- package/dist/call/treasury.d.ts.map +1 -1
- package/dist/call/treasury.js +29 -29
- package/dist/call/treasury.js.map +1 -1
- package/package.json +1 -1
- package/src/call/arbitration.ts +35 -34
- package/src/call/base.ts +6 -6
- package/src/call/demand.ts +26 -26
- package/src/call/machine.ts +35 -35
- package/src/call/permission.ts +8 -8
- package/src/call/personal.ts +2 -2
- package/src/call/repository.ts +20 -20
- package/src/call/service.ts +62 -56
- package/src/call/treasury.ts +29 -28
- package/tsconfig.tsbuildinfo +1 -1
package/src/call/arbitration.ts
CHANGED
|
@@ -45,21 +45,22 @@ export class CallArbitration extends CallBase {
|
|
|
45
45
|
|
|
46
46
|
protected async prepare() {
|
|
47
47
|
if (!this.object_address) {
|
|
48
|
-
this.object_address = (await LocalMark.Instance().get_address(GetObjectExisted(this.data.object)));
|
|
49
|
-
if (this.object_address) {
|
|
50
|
-
await this.update_content('Arbitration', this.object_address);
|
|
51
|
-
if (!this.content) ERROR(Errors.InvalidParam, 'CallArbitration_Data.data.object:' + this.data.object);
|
|
52
|
-
this.permission_address = (this.content as ObjectArbitration).permission;
|
|
53
|
-
this.type_parameter = Arbitration.parseObjectType(this.content.type_raw);
|
|
54
|
-
} else {
|
|
55
|
-
const n = GetObjectMain(this.data.object) as TypeNamedObjectWithPermission;
|
|
56
|
-
if (!IsValidArgType(n?.type_parameter)) {
|
|
57
|
-
ERROR(Errors.IsValidArgType, 'CallArbitration_Data.data.object.type_parameter');
|
|
58
|
-
}
|
|
59
|
-
this.permission_address = await LocalMark.Instance().get_address(GetObjectExisted(n?.permission));
|
|
60
|
-
this.type_parameter = n.type_parameter;
|
|
61
|
-
}
|
|
48
|
+
this.object_address = (await LocalMark.Instance().get_address(GetObjectExisted(this.data.object)));
|
|
62
49
|
}
|
|
50
|
+
|
|
51
|
+
if (this.object_address) {
|
|
52
|
+
await this.update_content('Arbitration', this.object_address);
|
|
53
|
+
if (!this.content) ERROR(Errors.InvalidParam, 'CallArbitration_Data.data.object:' + this.data.object);
|
|
54
|
+
this.permission_address = (this.content as ObjectArbitration).permission;
|
|
55
|
+
this.type_parameter = Arbitration.parseObjectType((this.content as ObjectArbitration).type_raw);
|
|
56
|
+
} else {
|
|
57
|
+
const n = GetObjectMain(this.data.object) as TypeNamedObjectWithPermission;
|
|
58
|
+
if (!IsValidArgType(n?.type_parameter)) {
|
|
59
|
+
ERROR(Errors.IsValidArgType, 'CallArbitration_Data.data.object.type_parameter');
|
|
60
|
+
}
|
|
61
|
+
this.permission_address = await LocalMark.Instance().get_address(GetObjectExisted(n?.permission));
|
|
62
|
+
this.type_parameter = Arbitration.parseObjectType(n.type_parameter);
|
|
63
|
+
}
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
async call(account?:string) : Promise<CallResult> {
|
|
@@ -71,32 +72,32 @@ export class CallArbitration extends CallBase {
|
|
|
71
72
|
if (!this.data?.object) {
|
|
72
73
|
perms.push(PermissionIndex.arbitration)
|
|
73
74
|
}
|
|
74
|
-
if (this.data?.description
|
|
75
|
+
if (this.data?.description != null && this.object_address) {
|
|
75
76
|
perms.push(PermissionIndex.arbitration_description)
|
|
76
77
|
}
|
|
77
|
-
if (this.data?.bPaused
|
|
78
|
+
if (this.data?.bPaused != null) {
|
|
78
79
|
perms.push(PermissionIndex.arbitration_pause)
|
|
79
80
|
}
|
|
80
|
-
if (this.data?.endpoint
|
|
81
|
+
if (this.data?.endpoint != null) { // publish is an irreversible one-time operation
|
|
81
82
|
perms.push(PermissionIndex.arbitration_endpoint)
|
|
82
83
|
}
|
|
83
|
-
if (this.data?.fee
|
|
84
|
+
if (this.data?.fee != null && this.object_address) {
|
|
84
85
|
perms.push(PermissionIndex.arbitration_fee)
|
|
85
86
|
}
|
|
86
|
-
if (this.data.fee_treasury
|
|
87
|
+
if (this.data.fee_treasury != null && this.object_address) {
|
|
87
88
|
perms.push(PermissionIndex.arbitration_treasury)
|
|
88
89
|
}
|
|
89
|
-
if (this.data?.guard
|
|
90
|
+
if (this.data?.guard != null) {
|
|
90
91
|
perms.push(PermissionIndex.arbitration_guard)
|
|
91
92
|
}
|
|
92
|
-
if (this.data?.voting_guard
|
|
93
|
+
if (this.data?.voting_guard != null) {
|
|
93
94
|
perms.push(PermissionIndex.arbitration_voting_guard)
|
|
94
95
|
}
|
|
95
|
-
if (this.data?.arb_arbitration
|
|
96
|
+
if (this.data?.arb_arbitration != null) {
|
|
96
97
|
perms.push(PermissionIndex.arbitration_arbitration)
|
|
97
98
|
}
|
|
98
99
|
|
|
99
|
-
if (this.data?.arb_new
|
|
100
|
+
if (this.data?.arb_new != null) { // new arb with guard and permission
|
|
100
101
|
if (this.object_address) {
|
|
101
102
|
if ((this.content as ObjectArbitration)?.usage_guard) {
|
|
102
103
|
guards.push((this.content as ObjectArbitration).usage_guard!)
|
|
@@ -104,7 +105,7 @@ export class CallArbitration extends CallBase {
|
|
|
104
105
|
}
|
|
105
106
|
}
|
|
106
107
|
|
|
107
|
-
if (this.data?.arb_vote
|
|
108
|
+
if (this.data?.arb_vote != null) {
|
|
108
109
|
perms.push(PermissionIndex.arbitration_vote);
|
|
109
110
|
|
|
110
111
|
const voting_guard = await LocalMark.Instance().get_address(this.data?.arb_vote?.voting_guard);
|
|
@@ -150,7 +151,7 @@ export class CallArbitration extends CallBase {
|
|
|
150
151
|
|
|
151
152
|
const pst = perm?undefined:passport;
|
|
152
153
|
var arb_new : ArbObject | undefined;
|
|
153
|
-
if (this.data?.arb_new
|
|
154
|
+
if (this.data?.arb_new != null) {
|
|
154
155
|
const d = this.data?.arb_new.data;
|
|
155
156
|
const fee = BigInt((this.object_address ? (this.content as ObjectArbitration)?.fee : this.data?.fee) ?? 0);
|
|
156
157
|
const max_fee = BigInt(d.max_fee ?? fee);
|
|
@@ -171,21 +172,21 @@ export class CallArbitration extends CallBase {
|
|
|
171
172
|
|
|
172
173
|
}
|
|
173
174
|
|
|
174
|
-
if (this.data?.arb_arbitration
|
|
175
|
+
if (this.data?.arb_arbitration != null) {
|
|
175
176
|
const a = await LocalMark.Instance().get_address(this.data.arb_arbitration.arb) ?? arb_new;
|
|
176
177
|
if (!a) ERROR(Errors.InvalidParam, 'CallArbitration_Data.data.arb_arbitration.arb');
|
|
177
178
|
|
|
178
179
|
obj?.arbitration({arb:a!, feedback:this.data.arb_arbitration.feedback, indemnity:this.data.arb_arbitration.indemnity}, pst)
|
|
179
180
|
}
|
|
180
181
|
|
|
181
|
-
if (this.data?.arb_vote
|
|
182
|
+
if (this.data?.arb_vote != null) {
|
|
182
183
|
const a = await LocalMark.Instance().get_address(this.data.arb_vote.arb) ?? arb_new;
|
|
183
184
|
if (!a) ERROR(Errors.InvalidParam, 'CallArbitration_Data.data.arb_vote.arb');
|
|
184
185
|
|
|
185
186
|
obj?.vote({arb:a!, voting_guard:this.data.arb_vote.voting_guard, agrees:this.data.arb_vote.agrees}, pst)
|
|
186
187
|
}
|
|
187
188
|
|
|
188
|
-
if (this.data?.arb_withdraw_fee
|
|
189
|
+
if (this.data?.arb_withdraw_fee != null) {
|
|
189
190
|
const a = await LocalMark.Instance().get_address(this.data.arb_withdraw_fee.arb);
|
|
190
191
|
if (!a) ERROR(Errors.InvalidParam, 'CallArbitration_Data.data.arb_withdraw_fee.arb');
|
|
191
192
|
|
|
@@ -196,16 +197,16 @@ export class CallArbitration extends CallBase {
|
|
|
196
197
|
await this.new_with_mark('Arb', txb, obj?.arb_launch(arb_new), (this.data?.arb_new as any)?.namedNew, account);
|
|
197
198
|
}
|
|
198
199
|
|
|
199
|
-
if (this.data?.description
|
|
200
|
+
if (this.data?.description != null && this.object_address) {
|
|
200
201
|
obj?.set_description(this.data.description, pst);
|
|
201
202
|
}
|
|
202
|
-
if (this.data?.endpoint
|
|
203
|
+
if (this.data?.endpoint != null) {
|
|
203
204
|
obj?.set_endpoint(this.data.endpoint, pst)
|
|
204
205
|
}
|
|
205
|
-
if (this.data?.fee
|
|
206
|
+
if (this.data?.fee != null && this.object_address) {
|
|
206
207
|
obj?.set_fee(BigInt(this.data.fee), pst)
|
|
207
208
|
}
|
|
208
|
-
if (this.data?.fee_treasury
|
|
209
|
+
if (this.data?.fee_treasury != null && this.object_address) {
|
|
209
210
|
const treasury_address = await LocalMark.Instance().get_address(GetObjectExisted(this.data.fee_treasury));
|
|
210
211
|
if (!treasury_address) {
|
|
211
212
|
withdraw_treasury = Treasury.New(txb, this.type_parameter!, permission,
|
|
@@ -223,7 +224,7 @@ export class CallArbitration extends CallBase {
|
|
|
223
224
|
obj?.set_guard(guard, pst)
|
|
224
225
|
}
|
|
225
226
|
|
|
226
|
-
if (this.data?.voting_guard
|
|
227
|
+
if (this.data?.voting_guard != null) {
|
|
227
228
|
switch (this.data.voting_guard.op) {
|
|
228
229
|
case 'add':
|
|
229
230
|
case 'set':
|
|
@@ -251,7 +252,7 @@ export class CallArbitration extends CallBase {
|
|
|
251
252
|
}
|
|
252
253
|
}
|
|
253
254
|
|
|
254
|
-
if (this.data?.bPaused
|
|
255
|
+
if (this.data?.bPaused != null) {
|
|
255
256
|
obj?.pause(this.data.bPaused, pst);
|
|
256
257
|
}
|
|
257
258
|
if (withdraw_treasury) {
|
package/src/call/base.ts
CHANGED
|
@@ -58,13 +58,13 @@ export const GetObjectParam = (object: ObjectParam | undefined) : NamedObjectWit
|
|
|
58
58
|
export type ObjectsOp = {op:'set' | 'add' | 'remove' ; objects:string[]} | {op:'removeall'};
|
|
59
59
|
|
|
60
60
|
// address from local Account or local Mark.
|
|
61
|
-
export type AccountOrMark_Address = {
|
|
61
|
+
export type AccountOrMark_Address = {account_or_address?: string} | {mark_or_address: string};
|
|
62
62
|
|
|
63
63
|
export const GetAccountOrMark_Address = async (entity?: AccountOrMark_Address) : Promise<string | undefined> => {
|
|
64
|
-
if (typeof((entity as any)?.
|
|
65
|
-
return await LocalMark.Instance().get_address((entity as any).
|
|
64
|
+
if (typeof((entity as any)?.mark_or_address) === 'string') {
|
|
65
|
+
return await LocalMark.Instance().get_address((entity as any).mark_or_address);
|
|
66
66
|
} else {
|
|
67
|
-
return (await Account.Instance().get((entity as any)?.
|
|
67
|
+
return (await Account.Instance().get((entity as any)?.account_or_address))?.address;
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
|
|
@@ -160,7 +160,7 @@ export class CallBase {
|
|
|
160
160
|
var guards : string[] = [];
|
|
161
161
|
|
|
162
162
|
if (permIndex.length > 0 || checkOwner) {
|
|
163
|
-
const p = await query_permission({permission_object:permission, address:{
|
|
163
|
+
const p = await query_permission({permission_object:permission, address:{account_or_address:account}});
|
|
164
164
|
if (checkOwner && !p.owner) ERROR(Errors.noPermission, 'owner');
|
|
165
165
|
if (checkAdmin && !p.admin) ERROR(Errors.noPermission, 'admin');
|
|
166
166
|
|
|
@@ -211,7 +211,7 @@ export class CallBase {
|
|
|
211
211
|
|
|
212
212
|
// onchain mark
|
|
213
213
|
if (!this.resouceObject) {
|
|
214
|
-
const r = await query_personal({address:{
|
|
214
|
+
const r = await query_personal({address:{account_or_address:account}});
|
|
215
215
|
if (!r?.mark_object) {
|
|
216
216
|
this.resouceObject = Entity.From(txb).create_resource2(); // new
|
|
217
217
|
Resource.From(txb, this.resouceObject).add(object, tags, named_new?.name);
|
package/src/call/demand.ts
CHANGED
|
@@ -35,21 +35,21 @@ export class CallDemand extends CallBase {
|
|
|
35
35
|
|
|
36
36
|
protected async prepare(): Promise<void> {
|
|
37
37
|
if (!this.object_address) {
|
|
38
|
-
this.object_address = (await LocalMark.Instance().get_address(GetObjectExisted(this.data.object)));
|
|
39
|
-
if (this.object_address) {
|
|
40
|
-
await this.update_content('Demand', this.object_address);
|
|
41
|
-
if (!this.content) ERROR(Errors.InvalidParam, 'CallDemand_Data.data.object:' + this.object_address);
|
|
42
|
-
this.permission_address = (this.content as ObjectDemand).permission;
|
|
43
|
-
this.type_parameter = Demand.parseObjectType(this.content.type_raw);
|
|
44
|
-
} else {
|
|
45
|
-
const n = GetObjectMain(this.data.object) as TypeNamedObjectWithPermission;
|
|
46
|
-
if (!IsValidArgType(n?.type_parameter)) {
|
|
47
|
-
ERROR(Errors.IsValidArgType, 'CallDemand_Data.data.object.type_parameter');
|
|
48
|
-
}
|
|
49
|
-
this.permission_address = (await LocalMark.Instance().get_address(GetObjectExisted(n?.permission)));
|
|
50
|
-
this.type_parameter = n.type_parameter;
|
|
51
|
-
}
|
|
38
|
+
this.object_address = (await LocalMark.Instance().get_address(GetObjectExisted(this.data.object)));
|
|
52
39
|
}
|
|
40
|
+
if (this.object_address) {
|
|
41
|
+
await this.update_content('Demand', this.object_address);
|
|
42
|
+
if (!this.content) ERROR(Errors.InvalidParam, 'CallDemand_Data.data.object:' + this.object_address);
|
|
43
|
+
this.permission_address = (this.content as ObjectDemand).permission;
|
|
44
|
+
this.type_parameter = Demand.parseObjectType((this.content as ObjectDemand).type_raw);
|
|
45
|
+
} else {
|
|
46
|
+
const n = GetObjectMain(this.data.object) as TypeNamedObjectWithPermission;
|
|
47
|
+
if (!IsValidArgType(n?.type_parameter)) {
|
|
48
|
+
ERROR(Errors.IsValidArgType, 'CallDemand_Data.data.object.type_parameter');
|
|
49
|
+
}
|
|
50
|
+
this.permission_address = (await LocalMark.Instance().get_address(GetObjectExisted(n?.permission)));
|
|
51
|
+
this.type_parameter = Demand.parseObjectType(n.type_parameter);
|
|
52
|
+
}
|
|
53
53
|
}
|
|
54
54
|
async call(account?:string) : Promise<CallResult> {
|
|
55
55
|
var checkOwner = false; const guards : string[] = [];
|
|
@@ -60,10 +60,10 @@ export class CallDemand extends CallBase {
|
|
|
60
60
|
if (!this.data?.object) {
|
|
61
61
|
perms.push(PermissionIndex.demand)
|
|
62
62
|
}
|
|
63
|
-
if (this.data?.description
|
|
63
|
+
if (this.data?.description != null && this.object_address) {
|
|
64
64
|
perms.push(PermissionIndex.demand_description)
|
|
65
65
|
}
|
|
66
|
-
if (this.data?.time_expire
|
|
66
|
+
if (this.data?.time_expire != null && this.object_address) {
|
|
67
67
|
perms.push(PermissionIndex.demand_expand_time)
|
|
68
68
|
}
|
|
69
69
|
if (this.data?.bounty?.op === 'reward') {
|
|
@@ -72,10 +72,10 @@ export class CallDemand extends CallBase {
|
|
|
72
72
|
if (this.data?.bounty?.op === 'refund') {
|
|
73
73
|
perms.push(PermissionIndex.demand_refund)
|
|
74
74
|
}
|
|
75
|
-
if (this.data?.guard
|
|
75
|
+
if (this.data?.guard != null) {
|
|
76
76
|
perms.push(PermissionIndex.demand_guard)
|
|
77
77
|
}
|
|
78
|
-
if (this.data?.present
|
|
78
|
+
if (this.data?.present != null) {
|
|
79
79
|
if (this.object_address) {
|
|
80
80
|
if ((this.content as ObjectDemand)?.guard?.object) {
|
|
81
81
|
guards.push((this.content as ObjectDemand).guard?.object!);
|
|
@@ -101,7 +101,7 @@ export class CallDemand extends CallBase {
|
|
|
101
101
|
permission = perm.get_object();
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
if (this.data.time_expire
|
|
104
|
+
if (this.data.time_expire != null) {
|
|
105
105
|
obj = Demand.New(txb, this.type_parameter!, this.data.time_expire?.op === 'duration' ? true : false,
|
|
106
106
|
this.data.time_expire?.op === 'duration' ? this.data.time_expire.minutes : this.data.time_expire?.time,
|
|
107
107
|
permission, this.data?.description??'', perm?undefined:passport)
|
|
@@ -115,8 +115,8 @@ export class CallDemand extends CallBase {
|
|
|
115
115
|
if (!permission) ERROR(Errors.InvalidParam, 'CallDemand_Data.data.object.permission');
|
|
116
116
|
|
|
117
117
|
const pst = perm?undefined:passport;
|
|
118
|
-
if (this.data?.present
|
|
119
|
-
if ((this.content as ObjectDemand)?.guard?.service_id_in_guard
|
|
118
|
+
if (this.data?.present != null) {
|
|
119
|
+
if ((this.content as ObjectDemand)?.guard?.service_id_in_guard != null && (this.content as ObjectDemand)?.guard?.service_id_in_guard !== null) {
|
|
120
120
|
obj?.present((this.content as ObjectDemand)!.guard!.service_id_in_guard!, undefined, this.data.present.recommend_words, pst);
|
|
121
121
|
} else {
|
|
122
122
|
const service_address = await LocalMark.Instance().get_address(this.data.present.service);
|
|
@@ -134,19 +134,19 @@ export class CallDemand extends CallBase {
|
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
if (this.data?.description
|
|
137
|
+
if (this.data?.description != null && this.object_address) {
|
|
138
138
|
obj?.set_description(this.data.description, pst);
|
|
139
139
|
}
|
|
140
|
-
if (this.data?.time_expire
|
|
140
|
+
if (this.data?.time_expire != null && this.object_address) {
|
|
141
141
|
obj?.expand_time(this.data.time_expire.op === 'duration' ? true : false,
|
|
142
142
|
this.data.time_expire.op === 'duration' ? this.data.time_expire.minutes : this.data.time_expire.time, pst)
|
|
143
143
|
}
|
|
144
|
-
if (this.data?.bounty
|
|
144
|
+
if (this.data?.bounty != null) {
|
|
145
145
|
if (this.data.bounty.op === 'add') {
|
|
146
146
|
const bounty = await LocalMark.Instance().get_address((this.data.bounty.object as any)?.address)
|
|
147
147
|
if (bounty) {
|
|
148
148
|
obj.deposit(bounty)
|
|
149
|
-
} else if ((this.data.bounty.object as any)?.balance
|
|
149
|
+
} else if ((this.data.bounty.object as any)?.balance != null){
|
|
150
150
|
const r = await Account.Instance().get_coin_object(txb, (this.data.bounty.object as any)?.balance, account, this.type_parameter);
|
|
151
151
|
if (r) obj.deposit(r)
|
|
152
152
|
}
|
|
@@ -159,7 +159,7 @@ export class CallDemand extends CallBase {
|
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
-
if (this.data?.guard
|
|
162
|
+
if (this.data?.guard != null) {
|
|
163
163
|
const guard = await LocalMark.Instance().get_address(this.data?.guard.address);
|
|
164
164
|
if (!guard) {
|
|
165
165
|
ERROR(Errors.InvalidParam, 'CallDemand_Data.data.guard.address')
|
package/src/call/machine.ts
CHANGED
|
@@ -50,16 +50,16 @@ export class CallMachine extends CallBase { //@ todo self-owned node operate
|
|
|
50
50
|
protected async prepare() {
|
|
51
51
|
if (!this.object_address) {
|
|
52
52
|
this.object_address = (await LocalMark.Instance().get_address(GetObjectExisted(this.data?.object)));
|
|
53
|
-
|
|
54
|
-
if (this.object_address) {
|
|
55
|
-
await this.update_content('Machine', this.object_address);
|
|
56
|
-
if (!this.content) ERROR(Errors.InvalidParam, 'CallMachine_Data.data.object:' + this.object_address);
|
|
57
|
-
this.permission_address = (this.content as ObjectMachine).permission;
|
|
58
|
-
} else {
|
|
59
|
-
const n = GetObjectMain(this.data?.object) as TypeNamedObjectWithPermission;
|
|
60
|
-
this.permission_address = (await LocalMark.Instance().get_address(GetObjectExisted(n?.permission)));
|
|
61
|
-
}
|
|
62
53
|
}
|
|
54
|
+
|
|
55
|
+
if (this.object_address) {
|
|
56
|
+
await this.update_content('Machine', this.object_address);
|
|
57
|
+
if (!this.content) ERROR(Errors.InvalidParam, 'CallMachine_Data.data.object:' + this.object_address);
|
|
58
|
+
this.permission_address = (this.content as ObjectMachine).permission;
|
|
59
|
+
} else {
|
|
60
|
+
const n = GetObjectMain(this.data?.object) as TypeNamedObjectWithPermission;
|
|
61
|
+
this.permission_address = (await LocalMark.Instance().get_address(GetObjectExisted(n?.permission)));
|
|
62
|
+
}
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
async call(account?:string) : Promise<CallResult> {
|
|
@@ -71,49 +71,49 @@ export class CallMachine extends CallBase { //@ todo self-owned node operate
|
|
|
71
71
|
if (!this.data?.object) {
|
|
72
72
|
perms.push(PermissionIndex.machine)
|
|
73
73
|
}
|
|
74
|
-
if (this.data?.description
|
|
74
|
+
if (this.data?.description != null && this.object_address) {
|
|
75
75
|
perms.push(PermissionIndex.machine_description)
|
|
76
76
|
}
|
|
77
|
-
if (this.data?.endpoint
|
|
77
|
+
if (this.data?.endpoint != null && this.object_address) {
|
|
78
78
|
perms.push(PermissionIndex.machine_endpoint)
|
|
79
79
|
}
|
|
80
|
-
if (this.data?.consensus_repository
|
|
80
|
+
if (this.data?.consensus_repository != null) {
|
|
81
81
|
perms.push(PermissionIndex.machine_repository)
|
|
82
82
|
}
|
|
83
|
-
if (this.data?.nodes
|
|
83
|
+
if (this.data?.nodes != null) {
|
|
84
84
|
perms.push(PermissionIndex.machine_node)
|
|
85
85
|
}
|
|
86
86
|
if (this.data?.bPublished) { // publish is an irreversible one-time operation
|
|
87
87
|
perms.push(PermissionIndex.machine_publish)
|
|
88
88
|
}
|
|
89
|
-
if (this.data?.progress_new
|
|
89
|
+
if (this.data?.progress_new != null) {
|
|
90
90
|
perms.push(PermissionIndex.progress)
|
|
91
91
|
}
|
|
92
|
-
if (this.data?.progress_context_repository
|
|
92
|
+
if (this.data?.progress_context_repository != null) {
|
|
93
93
|
perms.push(PermissionIndex.progress_context_repository)
|
|
94
94
|
}
|
|
95
|
-
if (this.data?.progress_namedOperator
|
|
95
|
+
if (this.data?.progress_namedOperator != null) {
|
|
96
96
|
perms.push(PermissionIndex.progress_namedOperator)
|
|
97
97
|
}
|
|
98
|
-
if (this.data?.progress_parent
|
|
98
|
+
if (this.data?.progress_parent != null) {
|
|
99
99
|
perms.push(PermissionIndex.progress_parent)
|
|
100
100
|
}
|
|
101
|
-
if (this.data?.progress_task
|
|
101
|
+
if (this.data?.progress_task != null) {
|
|
102
102
|
perms.push(PermissionIndex.progress_bind_task)
|
|
103
103
|
}
|
|
104
|
-
if (this.data?.progress_hold
|
|
104
|
+
if (this.data?.progress_hold != null) {
|
|
105
105
|
if (this.data.progress_hold.adminUnhold) {
|
|
106
106
|
perms.push(PermissionIndex.progress_unhold)
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
-
if (this.data?.bPaused
|
|
109
|
+
if (this.data?.bPaused != null) {
|
|
110
110
|
perms.push(PermissionIndex.machine_pause)
|
|
111
111
|
}
|
|
112
|
-
if (this.data?.clone_new
|
|
112
|
+
if (this.data?.clone_new!= null) {
|
|
113
113
|
perms.push(PermissionIndex.machine_clone)
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
if (this.data?.progress_next
|
|
116
|
+
if (this.data?.progress_next != null) {
|
|
117
117
|
if (this.object_address) { // fetch guard
|
|
118
118
|
const [p, acc] = await Promise.all([
|
|
119
119
|
LocalMark.Instance().get_address(this.data?.progress_next.progress),
|
|
@@ -159,11 +159,11 @@ export class CallMachine extends CallBase { //@ todo self-owned node operate
|
|
|
159
159
|
|
|
160
160
|
const pst = perm?undefined:passport;
|
|
161
161
|
var new_progress : Progress | undefined;
|
|
162
|
-
if (this.data?.progress_new
|
|
162
|
+
if (this.data?.progress_new != null) {
|
|
163
163
|
const task = await LocalMark.Instance().get_address(this.data?.progress_new?.task_address);
|
|
164
164
|
new_progress = Progress?.New(txb, obj?.get_object(), permission, task, pst);
|
|
165
165
|
}
|
|
166
|
-
if (this.data?.progress_context_repository
|
|
166
|
+
if (this.data?.progress_context_repository != null) {
|
|
167
167
|
const p = this.data?.progress_context_repository.progress
|
|
168
168
|
? await LocalMark.Instance().get_address(this.data?.progress_context_repository.progress)
|
|
169
169
|
: new_progress?.get_object();
|
|
@@ -171,7 +171,7 @@ export class CallMachine extends CallBase { //@ todo self-owned node operate
|
|
|
171
171
|
const rep = await LocalMark.Instance().get_address(this.data?.progress_context_repository.repository);
|
|
172
172
|
Progress.From(txb, obj?.get_object(), permission, p!).set_context_repository(rep, pst)
|
|
173
173
|
}
|
|
174
|
-
if (this.data?.progress_namedOperator
|
|
174
|
+
if (this.data?.progress_namedOperator != null) {
|
|
175
175
|
const p = this.data?.progress_namedOperator.progress
|
|
176
176
|
? await LocalMark.Instance().get_address(this.data?.progress_namedOperator.progress)
|
|
177
177
|
: new_progress?.get_object();
|
|
@@ -184,7 +184,7 @@ export class CallMachine extends CallBase { //@ todo self-owned node operate
|
|
|
184
184
|
pp.set_namedOperator(v.name, addrs, pst);
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
|
-
if (this.data?.progress_parent
|
|
187
|
+
if (this.data?.progress_parent != null) {
|
|
188
188
|
const p = this.data?.progress_parent.progress
|
|
189
189
|
? await LocalMark.Instance().get_address(this.data?.progress_parent.progress)
|
|
190
190
|
: new_progress?.get_object();
|
|
@@ -200,7 +200,7 @@ export class CallMachine extends CallBase { //@ todo self-owned node operate
|
|
|
200
200
|
Progress.From(txb, obj?.get_object(), permission, p!).parent_none();
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
|
-
if (this.data?.progress_hold
|
|
203
|
+
if (this.data?.progress_hold != null) {
|
|
204
204
|
const p = this.data?.progress_hold.progress
|
|
205
205
|
? await LocalMark.Instance().get_address(this.data?.progress_hold.progress)
|
|
206
206
|
: new_progress?.get_object();
|
|
@@ -212,11 +212,11 @@ export class CallMachine extends CallBase { //@ todo self-owned node operate
|
|
|
212
212
|
Progress.From(txb, obj?.get_object(), permission, p!).hold(this.data.progress_hold.operation, this.data.progress_hold.bHold)
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
|
-
if (this.data?.progress_task
|
|
215
|
+
if (this.data?.progress_task != null) {
|
|
216
216
|
const [p, task] = await LocalMark.Instance().get_many_address([this.data?.progress_task.progress, this.data?.progress_task.task_address]);
|
|
217
217
|
if (p && task) Progress.From(txb, obj?.get_object(), permission, p).bind_task(task, pst);
|
|
218
218
|
}
|
|
219
|
-
if (this.data?.progress_next
|
|
219
|
+
if (this.data?.progress_next != null) {
|
|
220
220
|
const p = await LocalMark.Instance().get_address(this.data?.progress_next.progress);
|
|
221
221
|
if (!p) ERROR(Errors.InvalidParam, 'CallMachine_Data.data.progress_next.progress');
|
|
222
222
|
var t: OrderWrap[] = [];
|
|
@@ -242,14 +242,14 @@ export class CallMachine extends CallBase { //@ todo self-owned node operate
|
|
|
242
242
|
await this.new_with_mark('Progress', txb, addr, this.data?.progress_new?.namedNew, account);
|
|
243
243
|
}
|
|
244
244
|
|
|
245
|
-
if (this.data?.description
|
|
245
|
+
if (this.data?.description != null && this.object_address) {
|
|
246
246
|
obj?.set_description(this.data.description, pst);
|
|
247
247
|
}
|
|
248
|
-
if (this.data?.endpoint
|
|
248
|
+
if (this.data?.endpoint != null && this.object_address) {
|
|
249
249
|
obj?.set_endpoint(this.data.endpoint, pst)
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
-
if (this.data?.consensus_repository
|
|
252
|
+
if (this.data?.consensus_repository != null) {
|
|
253
253
|
switch (this.data.consensus_repository.op) {
|
|
254
254
|
case 'add':
|
|
255
255
|
case 'set':
|
|
@@ -270,7 +270,7 @@ export class CallMachine extends CallBase { //@ todo self-owned node operate
|
|
|
270
270
|
break;
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
|
-
if (this.data?.nodes
|
|
273
|
+
if (this.data?.nodes != null) {
|
|
274
274
|
switch (this.data?.nodes?.op) {
|
|
275
275
|
case 'add':
|
|
276
276
|
obj?.add_node(this.data.nodes.data, pst)
|
|
@@ -299,10 +299,10 @@ export class CallMachine extends CallBase { //@ todo self-owned node operate
|
|
|
299
299
|
obj?.publish(passport)
|
|
300
300
|
}
|
|
301
301
|
|
|
302
|
-
if (this.data?.bPaused
|
|
302
|
+
if (this.data?.bPaused != null) {
|
|
303
303
|
obj?.pause(this.data.bPaused, pst)
|
|
304
304
|
}
|
|
305
|
-
if (this.data?.clone_new
|
|
305
|
+
if (this.data?.clone_new != null && this.object_address) {
|
|
306
306
|
await this.new_with_mark('Machine', txb, obj?.clone(true, pst) as TxbAddress, (this.data?.clone_new as any)?.namedNew, account);
|
|
307
307
|
}
|
|
308
308
|
if (perm) {
|
package/src/call/permission.ts
CHANGED
|
@@ -59,13 +59,13 @@ export class CallPermission extends CallBase {
|
|
|
59
59
|
|
|
60
60
|
await this.prepare();
|
|
61
61
|
if (this.object_address) {
|
|
62
|
-
if (this.data?.builder
|
|
62
|
+
if (this.data?.builder != null || this.data?.admin != null) {
|
|
63
63
|
checkOwner = true;
|
|
64
64
|
}
|
|
65
|
-
if (this.data?.permission
|
|
65
|
+
if (this.data?.permission != null || this.data?.biz_permission != null) {
|
|
66
66
|
checkAdmin = true;
|
|
67
67
|
}
|
|
68
|
-
if (this.data?.description
|
|
68
|
+
if (this.data?.description != null) {
|
|
69
69
|
checkAdmin = true;
|
|
70
70
|
}
|
|
71
71
|
return await this.check_permission_and_call(this.object_address, [], [], checkOwner, checkAdmin, account)
|
|
@@ -83,10 +83,10 @@ export class CallPermission extends CallBase {
|
|
|
83
83
|
|
|
84
84
|
if (!obj) ERROR(Errors.InvalidParam, 'CallPermission_Data.data.object');
|
|
85
85
|
|
|
86
|
-
if (this.data?.description
|
|
86
|
+
if (this.data?.description != null && this.data?.object) {
|
|
87
87
|
obj?.set_description(this.data.description)
|
|
88
88
|
}
|
|
89
|
-
if (this.data?.biz_permission
|
|
89
|
+
if (this.data?.biz_permission != null) { // High priority operate
|
|
90
90
|
switch(this.data.biz_permission.op) {
|
|
91
91
|
case 'add':
|
|
92
92
|
this.data.biz_permission.data.forEach(v => {
|
|
@@ -100,7 +100,7 @@ export class CallPermission extends CallBase {
|
|
|
100
100
|
break;
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
if (this.data?.permission
|
|
103
|
+
if (this.data?.permission != null) {
|
|
104
104
|
switch (this.data.permission.op) {
|
|
105
105
|
case 'add entity':
|
|
106
106
|
var add_entity:Wowok_Permission_Entity[] = [];
|
|
@@ -144,7 +144,7 @@ export class CallPermission extends CallBase {
|
|
|
144
144
|
break;
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
|
-
if (this.data?.admin
|
|
147
|
+
if (this.data?.admin != null) {
|
|
148
148
|
switch(this.data.admin?.op) {
|
|
149
149
|
case 'add':
|
|
150
150
|
case 'set':
|
|
@@ -161,7 +161,7 @@ export class CallPermission extends CallBase {
|
|
|
161
161
|
break;
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
|
-
if (this.data?.builder
|
|
164
|
+
if (this.data?.builder != null ) {
|
|
165
165
|
const b = await GetAccountOrMark_Address(this.data.builder);
|
|
166
166
|
if (b) obj?.change_owner(b);
|
|
167
167
|
}
|
package/src/call/personal.ts
CHANGED
|
@@ -26,14 +26,14 @@ export class CallPersonal extends CallBase {
|
|
|
26
26
|
}
|
|
27
27
|
protected async operate (txb:TransactionBlock, passport?:PassportObject, account?: string) {
|
|
28
28
|
let obj : Resource | undefined ; let entity: Entity = Entity.From(txb);
|
|
29
|
-
const entity_data = await query_personal({address:{
|
|
29
|
+
const entity_data = await query_personal({address:{account_or_address:account}});
|
|
30
30
|
if (entity_data?.mark_object) {
|
|
31
31
|
obj = Resource.From(txb, entity_data.mark_object);
|
|
32
32
|
} else {
|
|
33
33
|
obj = Resource.From(txb, entity.create_resource2());
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
if (this.data?.information
|
|
36
|
+
if (this.data?.information != null ) {
|
|
37
37
|
entity.update(this.data.information)
|
|
38
38
|
}
|
|
39
39
|
|