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/repository.ts
CHANGED
|
@@ -60,15 +60,15 @@ export class CallRepository extends CallBase {
|
|
|
60
60
|
|
|
61
61
|
protected async prepare(): Promise<void> {
|
|
62
62
|
if (!this.object_address) {
|
|
63
|
-
this.object_address = (await LocalMark.Instance().get(GetObjectExisted(this.data?.object)))?.address;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
63
|
+
this.object_address = (await LocalMark.Instance().get(GetObjectExisted(this.data?.object)))?.address;
|
|
64
|
+
}
|
|
65
|
+
if (this.object_address) {
|
|
66
|
+
await this.update_content('Repository', this.object_address);
|
|
67
|
+
if (!this.content) ERROR(Errors.InvalidParam, 'CallRepository_Data.data.object:' + this.object_address);
|
|
68
|
+
this.permission_address = (this.content as ObjectRepository).permission;
|
|
69
|
+
} else {
|
|
70
|
+
const n = GetObjectMain(this.data?.object) as TypeNamedObjectWithPermission;
|
|
71
|
+
this.permission_address = (await LocalMark.Instance().get_address(GetObjectExisted(n?.permission)));
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
async call(account?:string) : Promise<CallResult> {
|
|
@@ -80,16 +80,16 @@ export class CallRepository extends CallBase {
|
|
|
80
80
|
if (!this.data?.object) {
|
|
81
81
|
perms.push(PermissionIndex.repository)
|
|
82
82
|
}
|
|
83
|
-
if (this.data?.description
|
|
83
|
+
if (this.data?.description != null && this.object_address) {
|
|
84
84
|
perms.push(PermissionIndex.repository_description)
|
|
85
85
|
}
|
|
86
|
-
if (this.data?.mode
|
|
86
|
+
if (this.data?.mode != null && this.object_address) {
|
|
87
87
|
perms.push(PermissionIndex.repository_mode)
|
|
88
88
|
}
|
|
89
|
-
if (this.data?.reference
|
|
89
|
+
if (this.data?.reference != null) {
|
|
90
90
|
perms.push(PermissionIndex.repository_reference)
|
|
91
91
|
}
|
|
92
|
-
if (this.data?.policy
|
|
92
|
+
if (this.data?.policy != null) {
|
|
93
93
|
perms.push(PermissionIndex.repository_policies)
|
|
94
94
|
}
|
|
95
95
|
return await this.check_permission_and_call(this.permission_address, perms, [], checkOwner, undefined, account)
|
|
@@ -120,10 +120,10 @@ export class CallRepository extends CallBase {
|
|
|
120
120
|
if (!permission) ERROR(Errors.InvalidParam, 'CallRepository_Data.permission:' + this.permission_address);
|
|
121
121
|
|
|
122
122
|
const pst = perm?undefined:passport;
|
|
123
|
-
if (this.data?.description
|
|
123
|
+
if (this.data?.description != null && this.object_address) {
|
|
124
124
|
obj?.set_description(this.data.description, pst);
|
|
125
125
|
}
|
|
126
|
-
if (this.data?.reference
|
|
126
|
+
if (this.data?.reference != null) {
|
|
127
127
|
switch (this.data.reference.op) {
|
|
128
128
|
case 'set':
|
|
129
129
|
case 'add':
|
|
@@ -138,10 +138,10 @@ export class CallRepository extends CallBase {
|
|
|
138
138
|
break;
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
-
if (this.data?.mode
|
|
141
|
+
if (this.data?.mode != null && this.object_address) { //@ priority??
|
|
142
142
|
obj?.set_policy_mode(this.data.mode, pst)
|
|
143
143
|
}
|
|
144
|
-
if (this.data?.policy
|
|
144
|
+
if (this.data?.policy != null) {
|
|
145
145
|
switch(this.data.policy.op) {
|
|
146
146
|
case 'set':
|
|
147
147
|
obj?.remove_policies([], true, pst);
|
|
@@ -163,10 +163,10 @@ export class CallRepository extends CallBase {
|
|
|
163
163
|
break;
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
|
-
if (this.data?.data
|
|
166
|
+
if (this.data?.data != null) {
|
|
167
167
|
switch(this.data.data.op) {
|
|
168
168
|
case 'add':
|
|
169
|
-
if ((this.data.data?.data as any)?.key
|
|
169
|
+
if ((this.data.data?.data as any)?.key != null) {
|
|
170
170
|
const d = (this.data.data.data as Repository_Policy_Data).data;
|
|
171
171
|
const add: Wowok_Repository_Value[] = [];
|
|
172
172
|
for (let i=0; i<d.length; ++i) {
|
|
@@ -176,7 +176,7 @@ export class CallRepository extends CallBase {
|
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
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
|
|
179
|
+
} else if ((this.data.data?.data as any)?.address != null) {
|
|
180
180
|
const d = this.data.data.data as Repository_Policy_Data2;
|
|
181
181
|
const addr = await GetAddressID(d.address);
|
|
182
182
|
if (addr) {
|
package/src/call/service.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TransactionBlock, IsValidArgType, TxbAddress, TagName, PassportObject, Errors, ERROR, Permission,
|
|
2
|
-
PermissionIndex, PermissionIndexType, BuyRequiredEnum, Customer_RequiredInfo, Service, Service_Buy,
|
|
2
|
+
PermissionIndex, PermissionIndexType, BuyRequiredEnum, Customer_RequiredInfo, Service, Service_Buy as Wowok_Service_Buy,
|
|
3
3
|
Service_Guard_Percent, Service_Sale, Treasury, OrderResult, DicountDispatch as WowokDiscountDispatch,
|
|
4
4
|
ProgressObject, Arbitration, Service_Discount, PermissionObject,
|
|
5
5
|
} from 'wowok';
|
|
@@ -31,6 +31,12 @@ export interface RefundWithArb {
|
|
|
31
31
|
arb:string;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
export type Service_Buy = {
|
|
35
|
+
item: string; //
|
|
36
|
+
max_price: string | number | bigint;
|
|
37
|
+
count: string | number | bigint;
|
|
38
|
+
}
|
|
39
|
+
|
|
34
40
|
/// The execution priority is determined by the order in which the object attributes are arranged
|
|
35
41
|
export interface CallService_Data {
|
|
36
42
|
object: ObjectTypedMain;
|
|
@@ -76,94 +82,96 @@ export class CallService extends CallBase {
|
|
|
76
82
|
protected async prepare(): Promise<void> {
|
|
77
83
|
if (!this.object_address) {
|
|
78
84
|
this.object_address = (await LocalMark.Instance().get_address(GetObjectExisted(this.data.object)));
|
|
79
|
-
if (this.object_address) {
|
|
80
|
-
await this.update_content('Service', this.object_address);
|
|
81
|
-
if (!this.content) ERROR(Errors.InvalidParam, 'CallService_Data.data.object:' + this.object_address);
|
|
82
|
-
this.permission_address = (this.content as ObjectService).permission;
|
|
83
|
-
this.type_parameter = Service.parseObjectType(this.content.type_raw);
|
|
84
|
-
} else {
|
|
85
|
-
const n = GetObjectMain(this.data.object) as TypeNamedObjectWithPermission;
|
|
86
|
-
if (!IsValidArgType(n?.type_parameter)) {
|
|
87
|
-
ERROR(Errors.IsValidArgType, 'CallService_Data.data.object.type_parameter');
|
|
88
|
-
}
|
|
89
|
-
this.permission_address = (await LocalMark.Instance().get_address(GetObjectExisted(n?.permission)));
|
|
90
|
-
this.type_parameter = n.type_parameter;
|
|
91
|
-
}
|
|
92
85
|
}
|
|
86
|
+
|
|
87
|
+
if (this.object_address) {
|
|
88
|
+
await this.update_content('Service', this.object_address);
|
|
89
|
+
if (!this.content) ERROR(Errors.InvalidParam, 'CallService_Data.data.object:' + this.object_address);
|
|
90
|
+
|
|
91
|
+
this.permission_address = (this.content as ObjectService).permission;
|
|
92
|
+
this.type_parameter = Service.parseObjectType((this.content as ObjectService).type_raw);
|
|
93
|
+
} else {
|
|
94
|
+
const n = GetObjectMain(this.data.object) as TypeNamedObjectWithPermission;
|
|
95
|
+
if (!IsValidArgType(n?.type_parameter)) {
|
|
96
|
+
ERROR(Errors.IsValidArgType, 'CallService_Data.data.object.type_parameter');
|
|
97
|
+
}
|
|
98
|
+
this.permission_address = (await LocalMark.Instance().get_address(GetObjectExisted(n?.permission)));
|
|
99
|
+
this.type_parameter = Service.parseObjectType(n.type_parameter);
|
|
100
|
+
}
|
|
93
101
|
}
|
|
94
102
|
async call(account?:string) : Promise<CallResult> {
|
|
95
103
|
var checkOwner = false; const guards : string[] = [];
|
|
96
104
|
const perms : PermissionIndexType[] = [];
|
|
97
105
|
|
|
98
|
-
await this.prepare();
|
|
106
|
+
await this.prepare();
|
|
99
107
|
if (this.permission_address) {
|
|
100
108
|
if (!this.data?.object) {
|
|
101
109
|
perms.push(PermissionIndex.service)
|
|
102
110
|
}
|
|
103
|
-
if (this.data?.description
|
|
111
|
+
if (this.data?.description != null && this.object_address) {
|
|
104
112
|
perms.push(PermissionIndex.service_description)
|
|
105
113
|
}
|
|
106
|
-
if (this.data?.bPaused
|
|
114
|
+
if (this.data?.bPaused != null) {
|
|
107
115
|
perms.push(PermissionIndex.service_pause)
|
|
108
116
|
}
|
|
109
117
|
if (this.data?.bPublished) { // publish is an irreversible one-time operation
|
|
110
118
|
perms.push(PermissionIndex.service_publish)
|
|
111
119
|
}
|
|
112
|
-
if (this.data?.endpoint
|
|
120
|
+
if (this.data?.endpoint != null) {
|
|
113
121
|
perms.push(PermissionIndex.service_endpoint)
|
|
114
122
|
}
|
|
115
|
-
if (this.data?.repository
|
|
123
|
+
if (this.data?.repository != null) {
|
|
116
124
|
perms.push(PermissionIndex.service_repository)
|
|
117
125
|
}
|
|
118
|
-
if (this.data?.clone_new
|
|
126
|
+
if (this.data?.clone_new != null) {
|
|
119
127
|
perms.push(PermissionIndex.service_clone)
|
|
120
128
|
}
|
|
121
|
-
if (this.data?.gen_discount
|
|
129
|
+
if (this.data?.gen_discount != null) {
|
|
122
130
|
perms.push(PermissionIndex.service_discount_transfer)
|
|
123
131
|
}
|
|
124
|
-
if (this.data?.arbitration
|
|
132
|
+
if (this.data?.arbitration != null) {
|
|
125
133
|
perms.push(PermissionIndex.service_arbitration)
|
|
126
134
|
}
|
|
127
|
-
if (this.data?.buy_guard
|
|
135
|
+
if (this.data?.buy_guard != null) {
|
|
128
136
|
perms.push(PermissionIndex.service_buyer_guard)
|
|
129
137
|
}
|
|
130
|
-
if (this.data?.endpoint
|
|
138
|
+
if (this.data?.endpoint != null) {
|
|
131
139
|
perms.push(PermissionIndex.service_endpoint)
|
|
132
140
|
}
|
|
133
|
-
if (this.data?.extern_withdraw_treasury
|
|
141
|
+
if (this.data?.extern_withdraw_treasury != null) {
|
|
134
142
|
perms.push(PermissionIndex.service_treasury)
|
|
135
143
|
}
|
|
136
|
-
if (this.data?.machine
|
|
144
|
+
if (this.data?.machine != null) {
|
|
137
145
|
perms.push(PermissionIndex.service_machine)
|
|
138
146
|
}
|
|
139
|
-
if (this.data?.payee_treasury
|
|
147
|
+
if (this.data?.payee_treasury != null && this.object_address) {
|
|
140
148
|
perms.push(PermissionIndex.service_payee)
|
|
141
149
|
}
|
|
142
|
-
if (this.data?.withdraw_guard
|
|
150
|
+
if (this.data?.withdraw_guard != null) {
|
|
143
151
|
perms.push(PermissionIndex.service_withdraw_guards)
|
|
144
152
|
}
|
|
145
|
-
if (this.data?.refund_guard
|
|
153
|
+
if (this.data?.refund_guard != null) {
|
|
146
154
|
perms.push(PermissionIndex.service_refund_guards)
|
|
147
155
|
}
|
|
148
|
-
if (this.data?.customer_required_info
|
|
156
|
+
if (this.data?.customer_required_info != null) {
|
|
149
157
|
perms.push(PermissionIndex.service_customer_required)
|
|
150
158
|
}
|
|
151
|
-
if (this.data?.sales
|
|
159
|
+
if (this.data?.sales != null) {
|
|
152
160
|
perms.push(PermissionIndex.service_sales)
|
|
153
161
|
}
|
|
154
|
-
if (this.data?.order_new
|
|
162
|
+
if (this.data?.order_new != null) {
|
|
155
163
|
if (this.object_address) {
|
|
156
164
|
if ((this.content as ObjectService)?.buy_guard) {
|
|
157
165
|
guards.push((this.content as ObjectService).buy_guard!)
|
|
158
166
|
}
|
|
159
167
|
}
|
|
160
168
|
}
|
|
161
|
-
if ((this.data?.order_refund as RefundWithGuard)?.refund_guard
|
|
169
|
+
if ((this.data?.order_refund as RefundWithGuard)?.refund_guard != null) {
|
|
162
170
|
const guard = await LocalMark.Instance().get_address((this.data?.order_refund as RefundWithGuard)?.refund_guard);
|
|
163
171
|
if (guard) guards.push(guard);
|
|
164
172
|
}
|
|
165
173
|
|
|
166
|
-
if (this.data.order_withdrawl
|
|
174
|
+
if (this.data.order_withdrawl != null) { // permission(may be guard) + withdraw_guard
|
|
167
175
|
perms.push(PermissionIndex.service_withdraw)
|
|
168
176
|
}
|
|
169
177
|
|
|
@@ -227,7 +235,6 @@ export class CallService extends CallBase {
|
|
|
227
235
|
if (!t) {
|
|
228
236
|
ERROR(Errors.InvalidParam, 'CallService_Data.payee_treasury:' + (this.data.payee_treasury as any).address);
|
|
229
237
|
}
|
|
230
|
-
|
|
231
238
|
obj = Service.New(txb, this.type_parameter!, permission,
|
|
232
239
|
this.data?.description??'', t, perm?undefined:passport);
|
|
233
240
|
}
|
|
@@ -237,12 +244,11 @@ export class CallService extends CallBase {
|
|
|
237
244
|
|
|
238
245
|
const pst = perm?undefined:passport;
|
|
239
246
|
var order_new : OrderResult | undefined;
|
|
240
|
-
if (this.data?.order_new
|
|
247
|
+
if (this.data?.order_new != null && this.order_allowed()) {
|
|
241
248
|
let b = BigInt(0); let coin : any;
|
|
242
249
|
this.data.order_new.buy_items.forEach(v => {
|
|
243
250
|
b += BigInt(v.max_price) * BigInt(v.count)
|
|
244
251
|
});
|
|
245
|
-
|
|
246
252
|
coin = await Account.Instance().get_coin_object(txb, b, account, this.type_parameter);
|
|
247
253
|
if (coin) {
|
|
248
254
|
order_new = obj.order(this.data.order_new.buy_items, coin,
|
|
@@ -252,7 +258,7 @@ export class CallService extends CallBase {
|
|
|
252
258
|
}
|
|
253
259
|
}
|
|
254
260
|
|
|
255
|
-
if (this.data?.order_agent
|
|
261
|
+
if (this.data?.order_agent != null) {
|
|
256
262
|
const o = this.data.order_agent.order ? await LocalMark.Instance().get_address(this.data.order_agent.order) : order_new?.order;
|
|
257
263
|
if (!o) ERROR(Errors.InvalidParam, `CallService_Data.data.order_agent.order:${this.data.order_agent.order}`);
|
|
258
264
|
|
|
@@ -268,7 +274,7 @@ export class CallService extends CallBase {
|
|
|
268
274
|
obj?.update_order_required_info(o, crypto);
|
|
269
275
|
}
|
|
270
276
|
}
|
|
271
|
-
if (this.data?.order_refund
|
|
277
|
+
if (this.data?.order_refund != null) {
|
|
272
278
|
const o = await LocalMark.Instance().get_address(this.data.order_refund.order);
|
|
273
279
|
if (!o) ERROR(Errors.InvalidParam, `CallService_Data.data.order_agent.order:${this.data.order_refund.order}`);
|
|
274
280
|
|
|
@@ -283,7 +289,7 @@ export class CallService extends CallBase {
|
|
|
283
289
|
if (guard) obj?.refund(o!, guard, pst)
|
|
284
290
|
}
|
|
285
291
|
}
|
|
286
|
-
if (this.data?.order_withdrawl
|
|
292
|
+
if (this.data?.order_withdrawl != null && pst) { //@ need withdrawal pst
|
|
287
293
|
const n = this.data?.order_withdrawl;
|
|
288
294
|
const o = await LocalMark.Instance().get_address(n.order);
|
|
289
295
|
if (!o) ERROR(Errors.InvalidParam, `CallService_Data.data.order_agent.order:${this.data.order_withdrawl.order}`);
|
|
@@ -296,7 +302,7 @@ export class CallService extends CallBase {
|
|
|
296
302
|
index: n.data.index, for_guard:for_guard, for_object:for_object, remark:n.data.remark}, pst);
|
|
297
303
|
}
|
|
298
304
|
|
|
299
|
-
if (this.data?.order_payer
|
|
305
|
+
if (this.data?.order_payer != null) {
|
|
300
306
|
const o = this.data.order_payer.order ? await LocalMark.Instance().get_address(this.data.order_payer.order) : order_new?.order;
|
|
301
307
|
if (!o) ERROR(Errors.InvalidParam, `CallService_Data.data.order_agent.order:${this.data.order_payer.order}`);
|
|
302
308
|
|
|
@@ -313,13 +319,13 @@ export class CallService extends CallBase {
|
|
|
313
319
|
}
|
|
314
320
|
}
|
|
315
321
|
|
|
316
|
-
if (this.data?.description
|
|
322
|
+
if (this.data?.description != null && this.object_address) {
|
|
317
323
|
obj?.set_description(this.data.description, pst);
|
|
318
324
|
}
|
|
319
|
-
if (this.data?.endpoint
|
|
325
|
+
if (this.data?.endpoint != null) {
|
|
320
326
|
obj?.set_endpoint(this.data.endpoint, pst)
|
|
321
327
|
}
|
|
322
|
-
if (this.data?.payee_treasury
|
|
328
|
+
if (this.data?.payee_treasury != null && this.object_address) {
|
|
323
329
|
const treasury_address = await LocalMark.Instance().get_address(GetObjectExisted(this.data.payee_treasury));
|
|
324
330
|
if (!treasury_address) {
|
|
325
331
|
payee = Treasury.New(txb, this.type_parameter!, permission,
|
|
@@ -331,7 +337,7 @@ export class CallService extends CallBase {
|
|
|
331
337
|
}
|
|
332
338
|
obj?.set_payee(t, pst);
|
|
333
339
|
}
|
|
334
|
-
if (this.data?.gen_discount
|
|
340
|
+
if (this.data?.gen_discount != null) {
|
|
335
341
|
const add: WowokDiscountDispatch[] = [];
|
|
336
342
|
for (let i = 0; i < this.data.gen_discount.length; ++ i) {
|
|
337
343
|
let v = this.data.gen_discount[i];
|
|
@@ -342,7 +348,7 @@ export class CallService extends CallBase {
|
|
|
342
348
|
}
|
|
343
349
|
obj?.discount_transfer(add, pst)
|
|
344
350
|
}
|
|
345
|
-
if (this.data?.repository
|
|
351
|
+
if (this.data?.repository != null) {
|
|
346
352
|
switch (this.data.repository.op) {
|
|
347
353
|
case 'add':
|
|
348
354
|
case 'set':
|
|
@@ -363,7 +369,7 @@ export class CallService extends CallBase {
|
|
|
363
369
|
break;
|
|
364
370
|
}
|
|
365
371
|
}
|
|
366
|
-
if (this.data?.extern_withdraw_treasury
|
|
372
|
+
if (this.data?.extern_withdraw_treasury != null) {
|
|
367
373
|
switch(this.data.extern_withdraw_treasury.op) {
|
|
368
374
|
case 'add':
|
|
369
375
|
case 'set':
|
|
@@ -383,11 +389,11 @@ export class CallService extends CallBase {
|
|
|
383
389
|
break;
|
|
384
390
|
}
|
|
385
391
|
}
|
|
386
|
-
if (this.data?.machine
|
|
392
|
+
if (this.data?.machine != null) {
|
|
387
393
|
const machine = await LocalMark.Instance().get_address(this.data.machine);
|
|
388
394
|
obj?.set_machine(machine, pst)
|
|
389
395
|
}
|
|
390
|
-
if (this.data?.arbitration
|
|
396
|
+
if (this.data?.arbitration != null) {
|
|
391
397
|
switch(this.data.arbitration.op) {
|
|
392
398
|
case 'add':
|
|
393
399
|
case 'set':
|
|
@@ -407,14 +413,14 @@ export class CallService extends CallBase {
|
|
|
407
413
|
break;
|
|
408
414
|
}
|
|
409
415
|
}
|
|
410
|
-
if (this.data?.customer_required_info
|
|
416
|
+
if (this.data?.customer_required_info != null) {
|
|
411
417
|
if (this.data.customer_required_info.required_info.length > 0 && this.data.customer_required_info.pubkey) {
|
|
412
418
|
obj?.set_customer_required(this.data.customer_required_info.pubkey, this.data.customer_required_info.required_info, pst);
|
|
413
419
|
} else if (this.data.customer_required_info.pubkey) {
|
|
414
420
|
obj?.change_required_pubkey(this.data.customer_required_info.pubkey, pst);
|
|
415
421
|
}
|
|
416
422
|
}
|
|
417
|
-
if (this.data?.sales
|
|
423
|
+
if (this.data?.sales != null) {
|
|
418
424
|
switch(this.data.sales.op) {
|
|
419
425
|
case 'add':
|
|
420
426
|
obj?.add_sales(this.data.sales.sales, false, pst)
|
|
@@ -424,7 +430,7 @@ export class CallService extends CallBase {
|
|
|
424
430
|
break;
|
|
425
431
|
}
|
|
426
432
|
}
|
|
427
|
-
if (this.data?.withdraw_guard
|
|
433
|
+
if (this.data?.withdraw_guard != null) {
|
|
428
434
|
switch(this.data.withdraw_guard.op) {
|
|
429
435
|
case 'add':
|
|
430
436
|
case 'set':
|
|
@@ -449,7 +455,7 @@ export class CallService extends CallBase {
|
|
|
449
455
|
break;
|
|
450
456
|
}
|
|
451
457
|
}
|
|
452
|
-
if (this.data?.refund_guard
|
|
458
|
+
if (this.data?.refund_guard != null) {
|
|
453
459
|
switch(this.data.refund_guard.op) {
|
|
454
460
|
case 'add':
|
|
455
461
|
case 'set':
|
|
@@ -478,13 +484,13 @@ export class CallService extends CallBase {
|
|
|
478
484
|
obj?.publish(pst)
|
|
479
485
|
}
|
|
480
486
|
|
|
481
|
-
if (this.data?.buy_guard
|
|
487
|
+
if (this.data?.buy_guard != null) {
|
|
482
488
|
obj?.set_buy_guard(this.data.buy_guard, pst)
|
|
483
489
|
}
|
|
484
|
-
if (this.data?.bPaused
|
|
490
|
+
if (this.data?.bPaused != null) {
|
|
485
491
|
obj?.pause(this.data.bPaused, pst)
|
|
486
492
|
}
|
|
487
|
-
if (this.data?.clone_new
|
|
493
|
+
if (this.data?.clone_new != null) {
|
|
488
494
|
await this.new_with_mark('Service', txb, obj.clone(this.data.clone_new?.token_type_new, true, pst) as TxbAddress, (this.data?.clone_new as any)?.namedNew, account);
|
|
489
495
|
}
|
|
490
496
|
if (payee) {
|
package/src/call/treasury.ts
CHANGED
|
@@ -44,20 +44,21 @@ export class CallTreasury extends CallBase {
|
|
|
44
44
|
protected async prepare(): Promise<void> {
|
|
45
45
|
if (!this.object_address) {
|
|
46
46
|
this.object_address = (await LocalMark.Instance().get_address(GetObjectExisted(this.data.object)));
|
|
47
|
-
if (this.object_address) {
|
|
48
|
-
await this.update_content('Treasury', this.object_address);
|
|
49
|
-
if (!this.content) ERROR(Errors.InvalidParam, 'CallArbitration_Data.data.object:' + this.object_address);
|
|
50
|
-
this.permission_address = (this.content as ObjectTreasury).permission;
|
|
51
|
-
this.type_parameter = Treasury.parseObjectType(this.content.type_raw);
|
|
52
|
-
} else {
|
|
53
|
-
const n = GetObjectMain(this.data.object) as TypeNamedObjectWithPermission;
|
|
54
|
-
if (!IsValidArgType(n?.type_parameter)) {
|
|
55
|
-
ERROR(Errors.IsValidArgType, 'CallTreasury_Data.data.object.type_parameter');
|
|
56
|
-
}
|
|
57
|
-
this.permission_address = (await LocalMark.Instance().get_address(GetObjectExisted(n?.permission)));
|
|
58
|
-
this.type_parameter = n.type_parameter;
|
|
59
|
-
}
|
|
60
47
|
}
|
|
48
|
+
if (this.object_address) {
|
|
49
|
+
await this.update_content('Treasury', this.object_address);
|
|
50
|
+
if (!this.content) ERROR(Errors.InvalidParam, 'CallArbitration_Data.data.object:' + this.object_address);
|
|
51
|
+
|
|
52
|
+
this.permission_address = (this.content as ObjectTreasury).permission;
|
|
53
|
+
this.type_parameter = Treasury.parseObjectType((this.content as ObjectTreasury).type_raw);
|
|
54
|
+
} else {
|
|
55
|
+
const n = GetObjectMain(this.data.object) as TypeNamedObjectWithPermission;
|
|
56
|
+
if (!IsValidArgType(n?.type_parameter)) {
|
|
57
|
+
ERROR(Errors.IsValidArgType, 'CallTreasury_Data.data.object.type_parameter');
|
|
58
|
+
}
|
|
59
|
+
this.permission_address = (await LocalMark.Instance().get_address(GetObjectExisted(n?.permission)));
|
|
60
|
+
this.type_parameter = Treasury.parseObjectType(n.type_parameter);
|
|
61
|
+
}
|
|
61
62
|
}
|
|
62
63
|
async call(account?:string) : Promise<CallResult> {
|
|
63
64
|
var checkOwner = false; const guards : string[] = [];
|
|
@@ -68,32 +69,32 @@ export class CallTreasury extends CallBase {
|
|
|
68
69
|
if (!this.data?.object) {
|
|
69
70
|
perms.push(PermissionIndex.treasury)
|
|
70
71
|
}
|
|
71
|
-
if (this.data?.description
|
|
72
|
+
if (this.data?.description != null && this.object_address) {
|
|
72
73
|
perms.push(PermissionIndex.treasury_descritption)
|
|
73
74
|
}
|
|
74
|
-
if (this.data?.withdraw_mode
|
|
75
|
+
if (this.data?.withdraw_mode != null) {
|
|
75
76
|
perms.push(PermissionIndex.treasury_withdraw_mode)
|
|
76
77
|
}
|
|
77
|
-
if (this.data?.withdraw_guard
|
|
78
|
+
if (this.data?.withdraw_guard != null) { // publish is an irreversible one-time operation
|
|
78
79
|
perms.push(PermissionIndex.treasury_withdraw_guard)
|
|
79
80
|
}
|
|
80
|
-
if (this.data?.deposit_guard
|
|
81
|
+
if (this.data?.deposit_guard != null) {
|
|
81
82
|
perms.push(PermissionIndex.treasury_deposit_guard)
|
|
82
83
|
}
|
|
83
|
-
if (this.data?.deposit_guard
|
|
84
|
+
if (this.data?.deposit_guard != null) {
|
|
84
85
|
perms.push(PermissionIndex.treasury_deposit_guard)
|
|
85
86
|
}
|
|
86
|
-
if (this.data?.deposit
|
|
87
|
+
if (this.data?.deposit != null) {
|
|
87
88
|
if (this.object_address) {
|
|
88
89
|
if ((this.content as ObjectTreasury)?.deposit_guard) {
|
|
89
90
|
guards.push((this.content as ObjectTreasury).deposit_guard!)
|
|
90
91
|
}
|
|
91
92
|
}
|
|
92
93
|
}
|
|
93
|
-
if (this.data?.receive
|
|
94
|
+
if (this.data?.receive != null) {
|
|
94
95
|
perms.push(PermissionIndex.treasury_receive)
|
|
95
96
|
}
|
|
96
|
-
if (this.data?.withdraw?.withdraw_guard
|
|
97
|
+
if (this.data?.withdraw?.withdraw_guard != null) { // withdraw with guard
|
|
97
98
|
const guard = await get_object_address(this.data.withdraw.withdraw_guard);
|
|
98
99
|
if (guard) {
|
|
99
100
|
guards.push(guard)
|
|
@@ -128,7 +129,7 @@ export class CallTreasury extends CallBase {
|
|
|
128
129
|
if (!permission) ERROR(Errors.InvalidParam, 'CallTreasury_Data.permission:' + this.permission_address);
|
|
129
130
|
|
|
130
131
|
const pst = perm?undefined:passport;
|
|
131
|
-
if (this.data.deposit
|
|
132
|
+
if (this.data.deposit != null) {
|
|
132
133
|
const coin = await Account.Instance().get_coin_object(txb, this.data.deposit.balance, account, this.type_parameter);
|
|
133
134
|
if (coin) {
|
|
134
135
|
const index = this.data.deposit?.param?.index ?? 0;
|
|
@@ -136,7 +137,7 @@ export class CallTreasury extends CallBase {
|
|
|
136
137
|
obj?.deposit({coin:coin, index:BigInt(index), remark:this.data.deposit?.param?.remark ??'', for_guard, for_object});
|
|
137
138
|
}
|
|
138
139
|
}
|
|
139
|
-
if (this.data?.receive
|
|
140
|
+
if (this.data?.receive != null && this.object_address) {
|
|
140
141
|
if (this.data.receive === 'recently') {
|
|
141
142
|
const r = await Treasury.GetTreasuryRecievedObject(this.object_address, this.type_parameter!);
|
|
142
143
|
if (!r) {
|
|
@@ -161,7 +162,7 @@ export class CallTreasury extends CallBase {
|
|
|
161
162
|
}
|
|
162
163
|
}
|
|
163
164
|
|
|
164
|
-
if (this.data?.withdraw
|
|
165
|
+
if (this.data?.withdraw != null) {
|
|
165
166
|
const [for_guard, for_object] = await LocalMark.Instance().get_many_address([this.data.withdraw?.for_guard, this.data.withdraw?.for_object]);
|
|
166
167
|
const receiver = [];
|
|
167
168
|
for (let i=0;i < this.data.withdraw.receiver.length; ++i) {
|
|
@@ -175,14 +176,14 @@ export class CallTreasury extends CallBase {
|
|
|
175
176
|
for_guard, for_object, withdraw_guard: await LocalMark.Instance().get_address(this.data.withdraw.withdraw_guard)}, pst);
|
|
176
177
|
}
|
|
177
178
|
|
|
178
|
-
if (this.data?.description
|
|
179
|
+
if (this.data?.description != null && this.object_address) {
|
|
179
180
|
obj?.set_description(this.data.description, pst);
|
|
180
181
|
}
|
|
181
|
-
if (this.data?.deposit_guard
|
|
182
|
+
if (this.data?.deposit_guard != null) {
|
|
182
183
|
const guard = await LocalMark.Instance().get_address(this.data?.deposit_guard);
|
|
183
184
|
obj?.set_deposit_guard(guard, pst);
|
|
184
185
|
}
|
|
185
|
-
if (this.data?.withdraw_guard
|
|
186
|
+
if (this.data?.withdraw_guard != null) {
|
|
186
187
|
switch (this.data.withdraw_guard.op) {
|
|
187
188
|
case 'add':
|
|
188
189
|
case 'set':
|
|
@@ -202,7 +203,7 @@ export class CallTreasury extends CallBase {
|
|
|
202
203
|
break;
|
|
203
204
|
}
|
|
204
205
|
}
|
|
205
|
-
if (this.data?.withdraw_mode
|
|
206
|
+
if (this.data?.withdraw_mode != null) {
|
|
206
207
|
obj?.set_withdraw_mode(this.data.withdraw_mode, pst)
|
|
207
208
|
}
|
|
208
209
|
if (perm) {
|