wowok_agent 1.3.47 → 1.3.48
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 -0
- package/dist/call/arbitration.d.ts.map +1 -1
- package/dist/call/arbitration.js +137 -131
- package/dist/call/arbitration.js.map +1 -1
- package/dist/call/base.d.ts +4 -2
- package/dist/call/base.d.ts.map +1 -1
- package/dist/call/base.js +12 -4
- package/dist/call/base.js.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 +1 -0
- package/dist/call/machine.d.ts.map +1 -1
- package/dist/call/machine.js +156 -146
- package/dist/call/machine.js.map +1 -1
- package/dist/call/permission.d.ts +3 -2
- 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/repository.d.ts +1 -0
- package/dist/call/repository.d.ts.map +1 -1
- package/dist/call/repository.js +102 -92
- package/dist/call/repository.js.map +1 -1
- package/dist/call/service.d.ts +1 -0
- package/dist/call/service.d.ts.map +1 -1
- package/dist/call/service.js +272 -262
- package/dist/call/service.js.map +1 -1
- package/dist/call/treasury.d.ts +1 -0
- 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/package.json +1 -1
- package/src/call/arbitration.ts +140 -135
- package/src/call/base.ts +12 -6
- package/src/call/demand.ts +89 -81
- package/src/call/machine.ts +153 -141
- package/src/call/permission.ts +93 -85
- package/src/call/repository.ts +104 -92
- package/src/call/service.ts +272 -261
- package/src/call/treasury.ts +108 -96
- package/tsconfig.tsbuildinfo +1 -1
package/src/call/service.ts
CHANGED
|
@@ -2,7 +2,8 @@ import { TransactionBlock, IsValidArgType, TxbAddress, TagName, PassportObject,
|
|
|
2
2
|
PermissionIndex, PermissionIndexType, BuyRequiredEnum, Customer_RequiredInfo, Service, Service_Buy,
|
|
3
3
|
Service_Guard_Percent, Service_Sale, Treasury, OrderResult, DicountDispatch as WowokDiscountDispatch,
|
|
4
4
|
ProgressObject, Arbitration, Service_Discount,
|
|
5
|
-
ServiceObject,
|
|
5
|
+
ServiceObject,
|
|
6
|
+
PermissionObject,
|
|
6
7
|
} from 'wowok';
|
|
7
8
|
import { ObjectOrder, ObjectService, query_objects } from '../query/objects.js';
|
|
8
9
|
import { AccountOrMark_Address, CallBase, CallResult, GetAccountOrMark_Address, GetManyAccountOrMark_Address,
|
|
@@ -64,24 +65,30 @@ export class CallService extends CallBase {
|
|
|
64
65
|
super();
|
|
65
66
|
this.data = data;
|
|
66
67
|
}
|
|
68
|
+
|
|
69
|
+
protected async prepare(): Promise<void> {
|
|
70
|
+
if (!this.object_address) {
|
|
71
|
+
this.object_address = (await LocalMark.Instance().get_address(GetObjectExisted(this.data.object)));
|
|
72
|
+
if (this.object_address) {
|
|
73
|
+
await this.update_content('Service', this.object_address);
|
|
74
|
+
if (!this.content) ERROR(Errors.InvalidParam, 'CallService_Data.data.object:' + this.object_address);
|
|
75
|
+
this.permission_address = (this.content as ObjectService).permission;
|
|
76
|
+
this.type_parameter = Service.parseObjectType(this.content.type_raw);
|
|
77
|
+
} else {
|
|
78
|
+
const n = GetObjectMain(this.data.object) as TypeNamedObjectWithPermission;
|
|
79
|
+
if (!IsValidArgType(n?.type_parameter)) {
|
|
80
|
+
ERROR(Errors.IsValidArgType, 'CallService_Data.data.object.type_parameter');
|
|
81
|
+
}
|
|
82
|
+
this.permission_address = (await LocalMark.Instance().get_address(GetObjectExisted(n?.permission)));
|
|
83
|
+
this.type_parameter = n.type_parameter;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
67
87
|
async call(account?:string) : Promise<CallResult> {
|
|
68
88
|
var checkOwner = false; const guards : string[] = [];
|
|
69
89
|
const perms : PermissionIndexType[] = [];
|
|
70
|
-
this.object_address = (await LocalMark.Instance().get_address(GetObjectExisted(this.data.object)));
|
|
71
|
-
if (this.object_address) {
|
|
72
|
-
await this.update_content('Service', this.object_address);
|
|
73
|
-
if (!this.content) ERROR(Errors.InvalidParam, 'CallService_Data.data.object:' + this.object_address);
|
|
74
|
-
this.permission_address = (this.content as ObjectService).permission;
|
|
75
|
-
this.type_parameter = Service.parseObjectType(this.content.type_raw);
|
|
76
|
-
} else {
|
|
77
|
-
const n = GetObjectMain(this.data.object) as TypeNamedObjectWithPermission;
|
|
78
|
-
if (!IsValidArgType(n?.type_parameter)) {
|
|
79
|
-
ERROR(Errors.IsValidArgType, 'CallService_Data.data.object.type_parameter');
|
|
80
|
-
}
|
|
81
|
-
this.permission_address = (await LocalMark.Instance().get_address(GetObjectExisted(n?.permission)));
|
|
82
|
-
this.type_parameter = n.type_parameter;
|
|
83
|
-
}
|
|
84
90
|
|
|
91
|
+
await this.prepare();
|
|
85
92
|
if (this.permission_address) {
|
|
86
93
|
if (!this.data?.object) {
|
|
87
94
|
perms.push(PermissionIndex.service)
|
|
@@ -190,295 +197,299 @@ export class CallService extends CallBase {
|
|
|
190
197
|
}
|
|
191
198
|
|
|
192
199
|
protected async operate (txb:TransactionBlock, passport?:PassportObject, account?:string) {
|
|
193
|
-
let obj : Service | undefined ;
|
|
194
|
-
let permission:
|
|
200
|
+
let obj : Service | undefined ; let perm: Permission | undefined;
|
|
201
|
+
let permission : PermissionObject | undefined;
|
|
202
|
+
let payee: Treasury | undefined;
|
|
195
203
|
|
|
196
204
|
if (this.object_address) {
|
|
197
205
|
obj = Service.From(txb, this.type_parameter!, this.permission_address!, this.object_address);
|
|
206
|
+
permission = this.permission_address;
|
|
198
207
|
} else {
|
|
199
208
|
const n = GetObjectMain(this.data.object) as TypeNamedObjectWithPermission;
|
|
200
|
-
|
|
201
|
-
|
|
209
|
+
permission = await LocalMark.Instance().get_address(GetObjectExisted(n?.permission));
|
|
210
|
+
if (!permission) {
|
|
211
|
+
perm = Permission.New(txb, GetObjectParam(n?.permission)?.description ?? '');
|
|
212
|
+
permission = perm.get_object();
|
|
202
213
|
}
|
|
203
214
|
const treasury_address = await LocalMark.Instance().get_address(GetObjectExisted(this.data.payee_treasury));
|
|
204
215
|
if (!treasury_address) {
|
|
205
|
-
payee = Treasury.New(txb, this.type_parameter!, permission
|
|
206
|
-
GetObjectParam(this.data.payee_treasury)?.description ?? '',
|
|
216
|
+
payee = Treasury.New(txb, this.type_parameter!, permission,
|
|
217
|
+
GetObjectParam(this.data.payee_treasury)?.description ?? '', perm?undefined:passport);
|
|
207
218
|
}
|
|
208
219
|
const t = payee ? payee.get_object() : treasury_address;
|
|
209
220
|
if (!t) {
|
|
210
221
|
ERROR(Errors.InvalidParam, 'CallService_Data.payee_treasury:' + (this.data.payee_treasury as any).address);
|
|
211
222
|
}
|
|
212
223
|
|
|
213
|
-
obj = Service.New(txb, this.type_parameter!, permission
|
|
214
|
-
this.data?.description??'', t,
|
|
224
|
+
obj = Service.New(txb, this.type_parameter!, permission,
|
|
225
|
+
this.data?.description??'', t, perm?undefined:passport);
|
|
215
226
|
}
|
|
216
227
|
|
|
217
|
-
if (obj)
|
|
218
|
-
|
|
219
|
-
const pst = permission?undefined:passport;
|
|
220
|
-
var order_new : OrderResult | undefined;
|
|
221
|
-
if (this.data?.order_new !== undefined && this.order_allowed()) {
|
|
222
|
-
let b = BigInt(0); let coin : any;
|
|
223
|
-
this.data.order_new.buy_items.forEach(v => {
|
|
224
|
-
b += BigInt(v.max_price) * BigInt(v.count)
|
|
225
|
-
});
|
|
228
|
+
if (!obj) ERROR(Errors.InvalidParam, 'CallService_Data.object:' + this.object_address);
|
|
229
|
+
if (!permission) ERROR(Errors.InvalidParam, 'CallService_Data.permission:' + this.permission_address);
|
|
226
230
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
if (
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
231
|
+
const pst = perm?undefined:passport;
|
|
232
|
+
var order_new : OrderResult | undefined;
|
|
233
|
+
if (this.data?.order_new !== undefined && this.order_allowed()) {
|
|
234
|
+
let b = BigInt(0); let coin : any;
|
|
235
|
+
this.data.order_new.buy_items.forEach(v => {
|
|
236
|
+
b += BigInt(v.max_price) * BigInt(v.count)
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
coin = await Account.Instance().get_coin_object(txb, b, account, this.type_parameter);
|
|
240
|
+
if (coin) {
|
|
241
|
+
order_new = obj.order(this.data.order_new.buy_items, coin,
|
|
242
|
+
await LocalMark.Instance().get_address(this.data.order_new.discount_object),
|
|
243
|
+
(this?.content as ObjectService).machine!,
|
|
244
|
+
await this.info_crypto(this.data.order_new.customer_info_required), pst);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if (this.data?.order_agent !== undefined) {
|
|
249
|
+
const o = this.data.order_agent.order ? await LocalMark.Instance().get_address(this.data.order_agent.order) : order_new?.order;
|
|
250
|
+
if (!o) ERROR(Errors.InvalidParam, `CallService_Data.data.order_agent.order:${this.data.order_agent.order}`);
|
|
251
|
+
|
|
252
|
+
const p = await this.order_progress(this.data.order_agent.order, order_new);
|
|
253
|
+
const agents = await GetManyAccountOrMark_Address(this.data.order_agent.agents);
|
|
254
|
+
obj?.set_order_agent(o, agents.filter((v):v is string =>v!==undefined), p);
|
|
255
|
+
}
|
|
256
|
+
if (this.data?.order_required_info?.customer_info_required) {
|
|
257
|
+
const o = await LocalMark.Instance().get_address(this.data.order_required_info.order);
|
|
258
|
+
if (!o) ERROR(Errors.InvalidParam, `CallService_Data.data.order_required_info.order:${this.data.order_required_info.order}`);
|
|
259
|
+
const crypto = await this.info_crypto(this.object_address, this.data.order_required_info.customer_info_required);
|
|
260
|
+
if (crypto) {
|
|
261
|
+
obj?.update_order_required_info(o, crypto);
|
|
251
262
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
263
|
+
}
|
|
264
|
+
if (this.data?.order_refund !== undefined) {
|
|
265
|
+
const o = await LocalMark.Instance().get_address(this.data.order_refund.order);
|
|
266
|
+
if (!o) ERROR(Errors.InvalidParam, `CallService_Data.data.order_agent.order:${this.data.order_refund.order}`);
|
|
255
267
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
}
|
|
261
|
-
obj?.refund_withArb(o!, r?.objects[0].object, Arbitration.parseArbObjectType(r.objects[0].type_raw)!);
|
|
262
|
-
} else {
|
|
263
|
-
const guard = await LocalMark.Instance().get_address((this.data?.order_refund as any)?.guard);
|
|
264
|
-
if (guard) obj?.refund(o!, guard, pst)
|
|
268
|
+
if ((this.data?.order_refund as any)?.arb) {
|
|
269
|
+
const r = await query_objects({objects:[(this.data?.order_refund as any)?.arb]});
|
|
270
|
+
if (r?.objects?.length!== 1 || r?.objects[0]?.type!== 'Arb') {
|
|
271
|
+
ERROR(Errors.InvalidParam, 'order_refund.arb:' + (this.data?.order_refund as any)?.arb);
|
|
265
272
|
}
|
|
273
|
+
obj?.refund_withArb(o!, r?.objects[0].object, Arbitration.parseArbObjectType(r.objects[0].type_raw)!);
|
|
274
|
+
} else {
|
|
275
|
+
const guard = await LocalMark.Instance().get_address((this.data?.order_refund as any)?.guard);
|
|
276
|
+
if (guard) obj?.refund(o!, guard, pst)
|
|
266
277
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
278
|
+
}
|
|
279
|
+
if (this.data?.order_withdrawl !== undefined && pst) { //@ need withdrawal pst
|
|
280
|
+
const n = this.data?.order_withdrawl;
|
|
281
|
+
const o = await LocalMark.Instance().get_address(n.order);
|
|
282
|
+
if (!o) ERROR(Errors.InvalidParam, `CallService_Data.data.order_agent.order:${this.data.order_withdrawl.order}`);
|
|
271
283
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
284
|
+
const [for_guard, for_object, withdrawGuard] = await LocalMark.Instance().get_many_address(
|
|
285
|
+
[n.data.for_guard, n.data.for_object, n.data.withdraw_guard]);
|
|
286
|
+
if (!withdrawGuard) ERROR(Errors.InvalidParam, `CallService_Data.data.order_withdrawl.data.withdraw_guard:${this.data.order_withdrawl.data.withdraw_guard}`);
|
|
287
|
+
|
|
288
|
+
obj?.withdraw(o!, {withdraw_guard:withdrawGuard, treasury:(this.content as ObjectService).payee_treasury!,
|
|
289
|
+
index: n.data.index, for_guard:for_guard, for_object:for_object, remark:n.data.remark}, pst);
|
|
290
|
+
}
|
|
279
291
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
292
|
+
if (this.data?.order_payer !== undefined) {
|
|
293
|
+
const o = this.data.order_payer.order ? await LocalMark.Instance().get_address(this.data.order_payer.order) : order_new?.order;
|
|
294
|
+
if (!o) ERROR(Errors.InvalidParam, `CallService_Data.data.order_agent.order:${this.data.order_payer.order}`);
|
|
295
|
+
|
|
296
|
+
const p = await this.order_progress(this.data.order_payer.order, order_new);
|
|
297
|
+
const payer = await GetAccountOrMark_Address(this.data.order_payer.payer_new);
|
|
298
|
+
if (payer) obj?.change_order_payer(o, payer, p)
|
|
299
|
+
}
|
|
288
300
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
}
|
|
301
|
+
if (order_new && this?.data?.order_new) {
|
|
302
|
+
const buy = obj.order_launch(order_new);
|
|
303
|
+
await this.new_with_mark('Order', txb, buy.order, (this.data?.order_new as any)?.namedNewOrder, account, [TagName.Launch, TagName.Order]);
|
|
304
|
+
if (buy?.progress) {
|
|
305
|
+
await this.new_with_mark('Progress', txb, buy.progress, (this.data?.order_new as any)?.namedNewProgress, account, [TagName.Launch, 'progress']);
|
|
295
306
|
}
|
|
307
|
+
}
|
|
296
308
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
309
|
+
if (this.data?.description !== undefined && this.object_address) {
|
|
310
|
+
obj?.set_description(this.data.description, pst);
|
|
311
|
+
}
|
|
312
|
+
if (this.data?.endpoint !== undefined) {
|
|
313
|
+
obj?.set_endpoint(this.data.endpoint, pst)
|
|
314
|
+
}
|
|
315
|
+
if (this.data?.payee_treasury !== undefined && this.object_address) {
|
|
316
|
+
const treasury_address = await LocalMark.Instance().get_address(GetObjectExisted(this.data.payee_treasury));
|
|
317
|
+
if (!treasury_address) {
|
|
318
|
+
payee = Treasury.New(txb, this.type_parameter!, permission,
|
|
319
|
+
GetObjectParam(this.data.payee_treasury)?.description ?? '', permission?undefined:passport);
|
|
302
320
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
321
|
+
const t = payee ? payee.get_object() : treasury_address;
|
|
322
|
+
if (!t) {
|
|
323
|
+
ERROR(Errors.InvalidParam, 'CallService_Data.payee_treasury:' + (this.data.payee_treasury as any).address);
|
|
324
|
+
}
|
|
325
|
+
obj?.set_payee(t, pst);
|
|
326
|
+
}
|
|
327
|
+
if (this.data?.gen_discount !== undefined) {
|
|
328
|
+
const add: WowokDiscountDispatch[] = [];
|
|
329
|
+
for (let i = 0; i < this.data.gen_discount.length; ++ i) {
|
|
330
|
+
let v = this.data.gen_discount[i];
|
|
331
|
+
const addr = await GetAccountOrMark_Address(v.receiver);
|
|
332
|
+
if (addr) {
|
|
333
|
+
add.push({receiver:addr, count:v.count ?? 1, discount:v.discount})
|
|
308
334
|
}
|
|
309
|
-
const t = payee ? payee.get_object() : treasury_address;
|
|
310
|
-
if (!t) {
|
|
311
|
-
ERROR(Errors.InvalidParam, 'CallService_Data.payee_treasury:' + (this.data.payee_treasury as any).address);
|
|
312
|
-
}
|
|
313
|
-
obj?.set_payee(t, pst);
|
|
314
335
|
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
336
|
+
obj?.discount_transfer(add, pst)
|
|
337
|
+
}
|
|
338
|
+
if (this.data?.repository !== undefined) {
|
|
339
|
+
switch (this.data.repository.op) {
|
|
340
|
+
case 'add':
|
|
341
|
+
case 'set':
|
|
342
|
+
if (this.data.repository.op === 'set') obj?.remove_repository([], true, pst);
|
|
343
|
+
for (let i = 0; i < this.data.repository.repositories.length; ++ i) {
|
|
344
|
+
let v = this.data.repository.repositories[i];
|
|
345
|
+
const addr = await LocalMark.Instance().get_address(v);
|
|
346
|
+
if (addr) {
|
|
347
|
+
obj?.add_repository(addr, pst)
|
|
348
|
+
}
|
|
322
349
|
}
|
|
323
|
-
|
|
324
|
-
|
|
350
|
+
break;
|
|
351
|
+
case 'remove':
|
|
352
|
+
obj?.remove_repository(await LocalMark.Instance().get_many_address2(this.data.repository.repositories), false, pst)
|
|
353
|
+
break;
|
|
354
|
+
case 'removeall':
|
|
355
|
+
obj?.remove_repository([], true, pst)
|
|
356
|
+
break;
|
|
325
357
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
}
|
|
358
|
+
}
|
|
359
|
+
if (this.data?.extern_withdraw_treasury !== undefined) {
|
|
360
|
+
switch(this.data.extern_withdraw_treasury.op) {
|
|
361
|
+
case 'add':
|
|
362
|
+
case 'set':
|
|
363
|
+
if (this.data.extern_withdraw_treasury.op === 'set') obj?.remove_treasury([], true, pst);
|
|
364
|
+
const r = await query_objects({objects:this.data.extern_withdraw_treasury.treasuries, no_cache:true});
|
|
365
|
+
r.objects?.forEach(v => {
|
|
366
|
+
if (v.type ==='Treasury') {
|
|
367
|
+
obj?.add_treasury(v.object, Treasury.parseObjectType(v.type_raw), pst)
|
|
337
368
|
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
}
|
|
347
|
-
if (this.data?.extern_withdraw_treasury !== undefined) {
|
|
348
|
-
switch(this.data.extern_withdraw_treasury.op) {
|
|
349
|
-
case 'add':
|
|
350
|
-
case 'set':
|
|
351
|
-
if (this.data.extern_withdraw_treasury.op === 'set') obj?.remove_treasury([], true, pst);
|
|
352
|
-
const r = await query_objects({objects:this.data.extern_withdraw_treasury.treasuries, no_cache:true});
|
|
353
|
-
r.objects?.forEach(v => {
|
|
354
|
-
if (v.type ==='Treasury') {
|
|
355
|
-
obj?.add_treasury(v.object, Treasury.parseObjectType(v.type_raw), pst)
|
|
356
|
-
}
|
|
357
|
-
});
|
|
358
|
-
break;
|
|
359
|
-
case 'remove':
|
|
360
|
-
obj?.remove_treasury(await LocalMark.Instance().get_many_address2(this.data.extern_withdraw_treasury.treasuries), false, pst)
|
|
361
|
-
break;
|
|
362
|
-
case 'removeall':
|
|
363
|
-
obj?.remove_treasury([], false, pst)
|
|
364
|
-
break;
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
if (this.data?.machine !== undefined) {
|
|
368
|
-
const machine = await LocalMark.Instance().get_address(this.data.machine);
|
|
369
|
-
obj?.set_machine(machine, pst)
|
|
369
|
+
});
|
|
370
|
+
break;
|
|
371
|
+
case 'remove':
|
|
372
|
+
obj?.remove_treasury(await LocalMark.Instance().get_many_address2(this.data.extern_withdraw_treasury.treasuries), false, pst)
|
|
373
|
+
break;
|
|
374
|
+
case 'removeall':
|
|
375
|
+
obj?.remove_treasury([], false, pst)
|
|
376
|
+
break;
|
|
370
377
|
}
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
378
|
+
}
|
|
379
|
+
if (this.data?.machine !== undefined) {
|
|
380
|
+
const machine = await LocalMark.Instance().get_address(this.data.machine);
|
|
381
|
+
obj?.set_machine(machine, pst)
|
|
382
|
+
}
|
|
383
|
+
if (this.data?.arbitration !== undefined) {
|
|
384
|
+
switch(this.data.arbitration.op) {
|
|
385
|
+
case 'add':
|
|
386
|
+
case 'set':
|
|
387
|
+
if (this.data.arbitration.op === 'set') obj?.remove_arbitration([], true, pst);
|
|
388
|
+
const r = await query_objects({objects:this.data.arbitration.arbitrations, no_cache:true});
|
|
389
|
+
r.objects?.forEach(v => {
|
|
390
|
+
if (v.type ==='Arbitration') {
|
|
391
|
+
obj?.add_arbitration(v.object, Arbitration.parseObjectType(v.type_raw), pst)
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
break;
|
|
395
|
+
case 'remove':
|
|
396
|
+
obj?.remove_arbitration(await LocalMark.Instance().get_many_address2(this.data.arbitration.arbitrations), false, pst)
|
|
397
|
+
break;
|
|
398
|
+
case 'removeall':
|
|
399
|
+
obj?.remove_arbitration([], false, pst)
|
|
400
|
+
break;
|
|
390
401
|
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
402
|
+
}
|
|
403
|
+
if (this.data?.customer_required_info !== undefined) {
|
|
404
|
+
if (this.data.customer_required_info.required_info.length > 0 && this.data.customer_required_info.pubkey) {
|
|
405
|
+
obj?.set_customer_required(this.data.customer_required_info.pubkey, this.data.customer_required_info.required_info, pst);
|
|
406
|
+
} else if (this.data.customer_required_info.pubkey) {
|
|
407
|
+
obj?.change_required_pubkey(this.data.customer_required_info.pubkey, pst);
|
|
397
408
|
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
409
|
+
}
|
|
410
|
+
if (this.data?.sales !== undefined) {
|
|
411
|
+
switch(this.data.sales.op) {
|
|
412
|
+
case 'add':
|
|
413
|
+
obj?.add_sales(this.data.sales.sales, false, pst)
|
|
414
|
+
break;
|
|
415
|
+
case 'remove':
|
|
416
|
+
obj?.remove_sales(this.data.sales.sales_name, pst)
|
|
417
|
+
break;
|
|
407
418
|
}
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
419
|
+
}
|
|
420
|
+
if (this.data?.withdraw_guard !== undefined) {
|
|
421
|
+
switch(this.data.withdraw_guard.op) {
|
|
422
|
+
case 'add':
|
|
423
|
+
case 'set':
|
|
424
|
+
if (this.data.withdraw_guard.op === 'set') obj?.remove_withdraw_guards([], true, pst);
|
|
413
425
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
}
|
|
426
|
+
const add = []
|
|
427
|
+
for (let i = 0; i < this.data.withdraw_guard.guards.length; ++ i) {
|
|
428
|
+
let v = this.data.withdraw_guard.guards[i];
|
|
429
|
+
const addr = typeof(v.guard) === 'string' ? await LocalMark.Instance().get_address(v.guard as string) : v.guard;
|
|
430
|
+
if (addr) {
|
|
431
|
+
v.guard = addr;
|
|
432
|
+
add.push(v)
|
|
422
433
|
}
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
434
|
+
}
|
|
435
|
+
obj?.add_withdraw_guards(add, pst)
|
|
436
|
+
break;
|
|
437
|
+
case 'remove':
|
|
438
|
+
obj?.remove_withdraw_guards(await LocalMark.Instance().get_many_address2(this.data.withdraw_guard.guards), false, pst)
|
|
439
|
+
break;
|
|
440
|
+
case 'removeall':
|
|
441
|
+
obj?.remove_withdraw_guards([], true, pst)
|
|
442
|
+
break;
|
|
432
443
|
}
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
444
|
+
}
|
|
445
|
+
if (this.data?.refund_guard !== undefined) {
|
|
446
|
+
switch(this.data.refund_guard.op) {
|
|
447
|
+
case 'add':
|
|
448
|
+
case 'set':
|
|
449
|
+
if (this.data.refund_guard.op === 'set') obj?.remove_refund_guards([], true, pst);
|
|
450
|
+
const add = []
|
|
451
|
+
for (let i = 0; i < this.data.refund_guard.guards.length; ++ i) {
|
|
452
|
+
let v = this.data.refund_guard.guards[i];
|
|
453
|
+
const addr = typeof(v.guard) === 'string' ? await LocalMark.Instance().get_address(v.guard as string) : v.guard;
|
|
454
|
+
if (addr) {
|
|
455
|
+
v.guard = addr;
|
|
456
|
+
add.push(v)
|
|
446
457
|
}
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
}
|
|
458
|
-
if (this.data?.bPublished) {
|
|
459
|
-
obj?.publish(pst)
|
|
458
|
+
}
|
|
459
|
+
obj?.add_refund_guards(add, pst)
|
|
460
|
+
break;
|
|
461
|
+
|
|
462
|
+
case 'remove':
|
|
463
|
+
obj?.remove_refund_guards(await LocalMark.Instance().get_many_address2(this.data.refund_guard.guards), false, pst)
|
|
464
|
+
break;
|
|
465
|
+
case 'removeall':
|
|
466
|
+
obj?.remove_refund_guards([], true, pst)
|
|
467
|
+
break;
|
|
460
468
|
}
|
|
469
|
+
}
|
|
470
|
+
if (this.data?.bPublished) {
|
|
471
|
+
obj?.publish(pst)
|
|
472
|
+
}
|
|
461
473
|
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
}
|
|
468
|
-
if (this.data?.clone_new !== undefined) {
|
|
469
|
-
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);
|
|
470
|
-
}
|
|
471
|
-
if (payee) {
|
|
472
|
-
await this.new_with_mark('Treasury', txb, payee.launch(), GetObjectParam(this.data?.payee_treasury), account);
|
|
473
|
-
}
|
|
474
|
-
if (permission) {
|
|
475
|
-
const n = GetObjectMain(this.data.object) as TypeNamedObjectWithPermission;
|
|
476
|
-
await this.new_with_mark('Permission', txb, permission.launch(), GetObjectParam(n?.permission), account);
|
|
477
|
-
}
|
|
478
|
-
if (!this.object_address) {
|
|
479
|
-
await this.new_with_mark('Service', txb, obj.launch(), GetObjectMain(this.data?.object), account);
|
|
480
|
-
}
|
|
474
|
+
if (this.data?.buy_guard !== undefined) {
|
|
475
|
+
obj?.set_buy_guard(this.data.buy_guard, pst)
|
|
476
|
+
}
|
|
477
|
+
if (this.data?.bPaused !== undefined) {
|
|
478
|
+
obj?.pause(this.data.bPaused, pst)
|
|
481
479
|
}
|
|
480
|
+
if (this.data?.clone_new !== undefined) {
|
|
481
|
+
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);
|
|
482
|
+
}
|
|
483
|
+
if (payee) {
|
|
484
|
+
await this.new_with_mark('Treasury', txb, payee.launch(), GetObjectParam(this.data?.payee_treasury), account);
|
|
485
|
+
}
|
|
486
|
+
if (perm) {
|
|
487
|
+
const n = GetObjectMain(this.data.object) as TypeNamedObjectWithPermission;
|
|
488
|
+
await this.new_with_mark('Permission', txb, perm.launch(), GetObjectParam(n?.permission), account);
|
|
489
|
+
}
|
|
490
|
+
if (!this.object_address) {
|
|
491
|
+
await this.new_with_mark('Service', txb, obj.launch(), GetObjectMain(this.data?.object), account);
|
|
492
|
+
}
|
|
482
493
|
}
|
|
483
494
|
|
|
484
495
|
private info_crypto = async (object?:string, info?: string) : Promise<Customer_RequiredInfo | undefined>=> {
|