wowok_agent 1.3.47 → 1.3.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/call/arbitration.d.ts +4 -3
- package/dist/call/arbitration.d.ts.map +1 -1
- package/dist/call/arbitration.js +134 -131
- package/dist/call/arbitration.js.map +1 -1
- package/dist/call/base.d.ts +15 -7
- package/dist/call/base.d.ts.map +1 -1
- package/dist/call/base.js +21 -23
- package/dist/call/base.js.map +1 -1
- package/dist/call/call.d.ts +0 -6
- package/dist/call/call.d.ts.map +1 -1
- package/dist/call/demand.d.ts +1 -0
- package/dist/call/demand.d.ts.map +1 -1
- package/dist/call/demand.js +86 -80
- package/dist/call/demand.js.map +1 -1
- package/dist/call/machine.d.ts +10 -10
- package/dist/call/machine.d.ts.map +1 -1
- package/dist/call/machine.js +174 -146
- package/dist/call/machine.js.map +1 -1
- package/dist/call/permission.d.ts +10 -9
- package/dist/call/permission.d.ts.map +1 -1
- package/dist/call/permission.js +90 -85
- package/dist/call/permission.js.map +1 -1
- package/dist/call/personal.d.ts +3 -3
- package/dist/call/personal.d.ts.map +1 -1
- package/dist/call/personal.js +6 -12
- package/dist/call/personal.js.map +1 -1
- package/dist/call/repository.d.ts +24 -8
- package/dist/call/repository.d.ts.map +1 -1
- package/dist/call/repository.js +114 -94
- package/dist/call/repository.js.map +1 -1
- package/dist/call/service.d.ts +15 -26
- package/dist/call/service.d.ts.map +1 -1
- package/dist/call/service.js +274 -264
- package/dist/call/service.js.map +1 -1
- package/dist/call/treasury.d.ts +5 -7
- package/dist/call/treasury.d.ts.map +1 -1
- package/dist/call/treasury.js +108 -97
- package/dist/call/treasury.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/query/objects.d.ts +2 -1
- package/dist/query/objects.d.ts.map +1 -1
- package/dist/query/objects.js +7 -7
- package/dist/query/objects.js.map +1 -1
- package/dist/query/owned.d.ts +2 -0
- package/dist/query/owned.d.ts.map +1 -0
- package/dist/query/owned.js +2 -0
- package/dist/query/owned.js.map +1 -0
- package/dist/query/permission.d.ts +3 -2
- package/dist/query/permission.d.ts.map +1 -1
- package/dist/query/permission.js +6 -3
- package/dist/query/permission.js.map +1 -1
- package/dist/query/treasury_received.d.ts +14 -0
- package/dist/query/treasury_received.d.ts.map +1 -0
- package/dist/query/treasury_received.js +19 -0
- package/dist/query/treasury_received.js.map +1 -0
- package/package.json +1 -1
- package/src/call/arbitration.ts +144 -141
- package/src/call/base.ts +27 -29
- package/src/call/call.ts +6 -6
- package/src/call/demand.ts +89 -81
- package/src/call/machine.ts +184 -145
- package/src/call/permission.ts +98 -90
- package/src/call/personal.ts +8 -13
- package/src/call/repository.ts +138 -95
- package/src/call/service.ts +290 -272
- package/src/call/treasury.ts +110 -99
- package/src/index.ts +1 -0
- package/src/query/objects.ts +10 -10
- package/src/query/permission.ts +9 -6
- package/src/query/treasury_received.ts +35 -0
- package/tsconfig.tsbuildinfo +1 -1
package/src/call/service.ts
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import { TransactionBlock, IsValidArgType, TxbAddress, TagName, PassportObject, Errors, ERROR, Permission,
|
|
2
2
|
PermissionIndex, PermissionIndexType, BuyRequiredEnum, Customer_RequiredInfo, Service, Service_Buy,
|
|
3
3
|
Service_Guard_Percent, Service_Sale, Treasury, OrderResult, DicountDispatch as WowokDiscountDispatch,
|
|
4
|
-
ProgressObject, Arbitration, Service_Discount,
|
|
5
|
-
ServiceObject,
|
|
4
|
+
ProgressObject, Arbitration, Service_Discount, PermissionObject,
|
|
6
5
|
} from 'wowok';
|
|
7
6
|
import { ObjectOrder, ObjectService, query_objects } from '../query/objects.js';
|
|
8
7
|
import { AccountOrMark_Address, CallBase, CallResult, GetAccountOrMark_Address, GetManyAccountOrMark_Address,
|
|
9
|
-
GetObjectExisted, GetObjectMain, GetObjectParam, Namedbject, ObjectParam, ObjectTypedMain,
|
|
10
|
-
TypeNamedObjectWithPermission,
|
|
8
|
+
GetObjectExisted, GetObjectMain, GetObjectParam, Namedbject, ObjectParam, ObjectTypedMain, ObjectsOp,
|
|
9
|
+
TypeNamedObjectWithPermission, PayParam } from "./base.js";
|
|
11
10
|
import { Account } from '../local/account.js';
|
|
12
11
|
import { LocalMark } from '../local/local.js';
|
|
13
12
|
import { crypto_string } from '../common.js';
|
|
14
|
-
import { machine } from 'os';
|
|
15
13
|
|
|
16
|
-
export interface ServiceWithdraw extends
|
|
14
|
+
export interface ServiceWithdraw extends PayParam {
|
|
17
15
|
withdraw_guard: string;
|
|
18
16
|
}
|
|
19
17
|
|
|
@@ -23,6 +21,16 @@ export interface DicountDispatch {
|
|
|
23
21
|
count?: number;
|
|
24
22
|
}
|
|
25
23
|
|
|
24
|
+
export interface RefundWithGuard {
|
|
25
|
+
order:string;
|
|
26
|
+
refund_guard:string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface RefundWithArb {
|
|
30
|
+
order:string;
|
|
31
|
+
arb:string;
|
|
32
|
+
}
|
|
33
|
+
|
|
26
34
|
/// The execution priority is determined by the order in which the object attributes are arranged
|
|
27
35
|
export interface CallService_Data {
|
|
28
36
|
object: ObjectTypedMain;
|
|
@@ -30,7 +38,7 @@ export interface CallService_Data {
|
|
|
30
38
|
namedNewOrder?: Namedbject, namedNewProgress?:Namedbject}
|
|
31
39
|
order_agent?: {order?:string; agents: AccountOrMark_Address[];};
|
|
32
40
|
order_required_info?: {order:string; customer_info_required?:string};
|
|
33
|
-
order_refund?:
|
|
41
|
+
order_refund?: RefundWithGuard | RefundWithArb;
|
|
34
42
|
order_withdrawl?: {order:string; data:ServiceWithdraw}; // guard address
|
|
35
43
|
order_payer?: {order?:string; payer_new:AccountOrMark_Address; }; // transfer the order payer permission to someaddress
|
|
36
44
|
|
|
@@ -38,10 +46,10 @@ export interface CallService_Data {
|
|
|
38
46
|
endpoint?: string;
|
|
39
47
|
payee_treasury?:ObjectParam;
|
|
40
48
|
gen_discount?: DicountDispatch[];
|
|
41
|
-
repository?:
|
|
42
|
-
extern_withdraw_treasury?:
|
|
49
|
+
repository?: ObjectsOp;
|
|
50
|
+
extern_withdraw_treasury?: ObjectsOp;
|
|
43
51
|
machine?: string;
|
|
44
|
-
arbitration?:
|
|
52
|
+
arbitration?: ObjectsOp;
|
|
45
53
|
customer_required_info?: {pubkey:string; required_info:(string | BuyRequiredEnum)[]};
|
|
46
54
|
sales?: {op:'add', sales:Service_Sale[]} | {op:'remove'; sales_name:string[]}
|
|
47
55
|
withdraw_guard?: {op:'add' | 'set'; guards:Service_Guard_Percent[]}
|
|
@@ -64,24 +72,30 @@ export class CallService extends CallBase {
|
|
|
64
72
|
super();
|
|
65
73
|
this.data = data;
|
|
66
74
|
}
|
|
75
|
+
|
|
76
|
+
protected async prepare(): Promise<void> {
|
|
77
|
+
if (!this.object_address) {
|
|
78
|
+
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
|
+
}
|
|
93
|
+
}
|
|
67
94
|
async call(account?:string) : Promise<CallResult> {
|
|
68
95
|
var checkOwner = false; const guards : string[] = [];
|
|
69
96
|
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
97
|
|
|
98
|
+
await this.prepare();
|
|
85
99
|
if (this.permission_address) {
|
|
86
100
|
if (!this.data?.object) {
|
|
87
101
|
perms.push(PermissionIndex.service)
|
|
@@ -144,8 +158,8 @@ export class CallService extends CallBase {
|
|
|
144
158
|
}
|
|
145
159
|
}
|
|
146
160
|
}
|
|
147
|
-
if (this.data
|
|
148
|
-
const guard = await LocalMark.Instance().get_address((this.data?.order_refund as
|
|
161
|
+
if ((this.data?.order_refund as RefundWithGuard)?.refund_guard !== undefined) {
|
|
162
|
+
const guard = await LocalMark.Instance().get_address((this.data?.order_refund as RefundWithGuard)?.refund_guard);
|
|
149
163
|
if (guard) guards.push(guard);
|
|
150
164
|
}
|
|
151
165
|
|
|
@@ -190,295 +204,299 @@ export class CallService extends CallBase {
|
|
|
190
204
|
}
|
|
191
205
|
|
|
192
206
|
protected async operate (txb:TransactionBlock, passport?:PassportObject, account?:string) {
|
|
193
|
-
let obj : Service | undefined ;
|
|
194
|
-
let permission:
|
|
207
|
+
let obj : Service | undefined ; let perm: Permission | undefined;
|
|
208
|
+
let permission : PermissionObject | undefined;
|
|
209
|
+
let payee: Treasury | undefined;
|
|
195
210
|
|
|
196
211
|
if (this.object_address) {
|
|
197
212
|
obj = Service.From(txb, this.type_parameter!, this.permission_address!, this.object_address);
|
|
213
|
+
permission = this.permission_address;
|
|
198
214
|
} else {
|
|
199
215
|
const n = GetObjectMain(this.data.object) as TypeNamedObjectWithPermission;
|
|
200
|
-
|
|
201
|
-
|
|
216
|
+
permission = await LocalMark.Instance().get_address(GetObjectExisted(n?.permission));
|
|
217
|
+
if (!permission) {
|
|
218
|
+
perm = Permission.New(txb, GetObjectParam(n?.permission)?.description ?? '');
|
|
219
|
+
permission = perm.get_object();
|
|
202
220
|
}
|
|
203
221
|
const treasury_address = await LocalMark.Instance().get_address(GetObjectExisted(this.data.payee_treasury));
|
|
204
222
|
if (!treasury_address) {
|
|
205
|
-
payee = Treasury.New(txb, this.type_parameter!, permission
|
|
206
|
-
GetObjectParam(this.data.payee_treasury)?.description ?? '',
|
|
223
|
+
payee = Treasury.New(txb, this.type_parameter!, permission,
|
|
224
|
+
GetObjectParam(this.data.payee_treasury)?.description ?? '', perm?undefined:passport);
|
|
207
225
|
}
|
|
208
226
|
const t = payee ? payee.get_object() : treasury_address;
|
|
209
227
|
if (!t) {
|
|
210
228
|
ERROR(Errors.InvalidParam, 'CallService_Data.payee_treasury:' + (this.data.payee_treasury as any).address);
|
|
211
229
|
}
|
|
212
230
|
|
|
213
|
-
obj = Service.New(txb, this.type_parameter!, permission
|
|
214
|
-
this.data?.description??'', t,
|
|
231
|
+
obj = Service.New(txb, this.type_parameter!, permission,
|
|
232
|
+
this.data?.description??'', t, perm?undefined:passport);
|
|
215
233
|
}
|
|
216
234
|
|
|
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
|
-
});
|
|
235
|
+
if (!obj) ERROR(Errors.InvalidParam, 'CallService_Data.object:' + this.object_address);
|
|
236
|
+
if (!permission) ERROR(Errors.InvalidParam, 'CallService_Data.permission:' + this.permission_address);
|
|
226
237
|
|
|
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
|
-
|
|
238
|
+
const pst = perm?undefined:passport;
|
|
239
|
+
var order_new : OrderResult | undefined;
|
|
240
|
+
if (this.data?.order_new !== undefined && this.order_allowed()) {
|
|
241
|
+
let b = BigInt(0); let coin : any;
|
|
242
|
+
this.data.order_new.buy_items.forEach(v => {
|
|
243
|
+
b += BigInt(v.max_price) * BigInt(v.count)
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
coin = await Account.Instance().get_coin_object(txb, b, account, this.type_parameter);
|
|
247
|
+
if (coin) {
|
|
248
|
+
order_new = obj.order(this.data.order_new.buy_items, coin,
|
|
249
|
+
await LocalMark.Instance().get_address(this.data.order_new.discount_object),
|
|
250
|
+
(this?.content as ObjectService).machine!,
|
|
251
|
+
await this.info_crypto(this.data.order_new.customer_info_required), pst);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
if (this.data?.order_agent !== undefined) {
|
|
256
|
+
const o = this.data.order_agent.order ? await LocalMark.Instance().get_address(this.data.order_agent.order) : order_new?.order;
|
|
257
|
+
if (!o) ERROR(Errors.InvalidParam, `CallService_Data.data.order_agent.order:${this.data.order_agent.order}`);
|
|
258
|
+
|
|
259
|
+
const p = await this.order_progress(this.data.order_agent.order, order_new);
|
|
260
|
+
const agents = await GetManyAccountOrMark_Address(this.data.order_agent.agents);
|
|
261
|
+
obj?.set_order_agent(o, agents.filter((v):v is string =>v!==undefined), p);
|
|
262
|
+
}
|
|
263
|
+
if (this.data?.order_required_info?.customer_info_required) {
|
|
264
|
+
const o = await LocalMark.Instance().get_address(this.data.order_required_info.order);
|
|
265
|
+
if (!o) ERROR(Errors.InvalidParam, `CallService_Data.data.order_required_info.order:${this.data.order_required_info.order}`);
|
|
266
|
+
const crypto = await this.info_crypto(this.object_address, this.data.order_required_info.customer_info_required);
|
|
267
|
+
if (crypto) {
|
|
268
|
+
obj?.update_order_required_info(o, crypto);
|
|
251
269
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
270
|
+
}
|
|
271
|
+
if (this.data?.order_refund !== undefined) {
|
|
272
|
+
const o = await LocalMark.Instance().get_address(this.data.order_refund.order);
|
|
273
|
+
if (!o) ERROR(Errors.InvalidParam, `CallService_Data.data.order_agent.order:${this.data.order_refund.order}`);
|
|
255
274
|
|
|
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)
|
|
275
|
+
if ((this.data?.order_refund as any)?.arb) {
|
|
276
|
+
const r = await query_objects({objects:[(this.data?.order_refund as any)?.arb]});
|
|
277
|
+
if (r?.objects?.length!== 1 || r?.objects[0]?.type!== 'Arb') {
|
|
278
|
+
ERROR(Errors.InvalidParam, 'order_refund.arb:' + (this.data?.order_refund as any)?.arb);
|
|
265
279
|
}
|
|
280
|
+
obj?.refund_withArb(o!, r?.objects[0].object, Arbitration.parseArbObjectType(r.objects[0].type_raw)!);
|
|
281
|
+
} else {
|
|
282
|
+
const guard = await LocalMark.Instance().get_address((this.data?.order_refund as RefundWithGuard)?.refund_guard);
|
|
283
|
+
if (guard) obj?.refund(o!, guard, pst)
|
|
266
284
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
285
|
+
}
|
|
286
|
+
if (this.data?.order_withdrawl !== undefined && pst) { //@ need withdrawal pst
|
|
287
|
+
const n = this.data?.order_withdrawl;
|
|
288
|
+
const o = await LocalMark.Instance().get_address(n.order);
|
|
289
|
+
if (!o) ERROR(Errors.InvalidParam, `CallService_Data.data.order_agent.order:${this.data.order_withdrawl.order}`);
|
|
271
290
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
291
|
+
const [for_guard, for_object, withdrawGuard] = await LocalMark.Instance().get_many_address(
|
|
292
|
+
[n.data.for_guard, n.data.for_object, n.data.withdraw_guard]);
|
|
293
|
+
if (!withdrawGuard) ERROR(Errors.InvalidParam, `CallService_Data.data.order_withdrawl.data.withdraw_guard:${this.data.order_withdrawl.data.withdraw_guard}`);
|
|
294
|
+
|
|
295
|
+
obj?.withdraw(o!, {withdraw_guard:withdrawGuard, treasury:(this.content as ObjectService).payee_treasury!,
|
|
296
|
+
index: n.data.index, for_guard:for_guard, for_object:for_object, remark:n.data.remark}, pst);
|
|
297
|
+
}
|
|
279
298
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
299
|
+
if (this.data?.order_payer !== undefined) {
|
|
300
|
+
const o = this.data.order_payer.order ? await LocalMark.Instance().get_address(this.data.order_payer.order) : order_new?.order;
|
|
301
|
+
if (!o) ERROR(Errors.InvalidParam, `CallService_Data.data.order_agent.order:${this.data.order_payer.order}`);
|
|
302
|
+
|
|
303
|
+
const p = await this.order_progress(this.data.order_payer.order, order_new);
|
|
304
|
+
const payer = await GetAccountOrMark_Address(this.data.order_payer.payer_new);
|
|
305
|
+
if (payer) obj?.change_order_payer(o, payer, p)
|
|
306
|
+
}
|
|
288
307
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
}
|
|
308
|
+
if (order_new && this?.data?.order_new) {
|
|
309
|
+
const buy = obj.order_launch(order_new);
|
|
310
|
+
await this.new_with_mark('Order', txb, buy.order, (this.data?.order_new as any)?.namedNewOrder, account, [TagName.Launch, TagName.Order]);
|
|
311
|
+
if (buy?.progress) {
|
|
312
|
+
await this.new_with_mark('Progress', txb, buy.progress, (this.data?.order_new as any)?.namedNewProgress, account, [TagName.Launch, 'progress']);
|
|
295
313
|
}
|
|
314
|
+
}
|
|
296
315
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
316
|
+
if (this.data?.description !== undefined && this.object_address) {
|
|
317
|
+
obj?.set_description(this.data.description, pst);
|
|
318
|
+
}
|
|
319
|
+
if (this.data?.endpoint !== undefined) {
|
|
320
|
+
obj?.set_endpoint(this.data.endpoint, pst)
|
|
321
|
+
}
|
|
322
|
+
if (this.data?.payee_treasury !== undefined && this.object_address) {
|
|
323
|
+
const treasury_address = await LocalMark.Instance().get_address(GetObjectExisted(this.data.payee_treasury));
|
|
324
|
+
if (!treasury_address) {
|
|
325
|
+
payee = Treasury.New(txb, this.type_parameter!, permission,
|
|
326
|
+
GetObjectParam(this.data.payee_treasury)?.description ?? '', permission?undefined:passport);
|
|
302
327
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
328
|
+
const t = payee ? payee.get_object() : treasury_address;
|
|
329
|
+
if (!t) {
|
|
330
|
+
ERROR(Errors.InvalidParam, 'CallService_Data.payee_treasury:' + (this.data.payee_treasury as any).address);
|
|
331
|
+
}
|
|
332
|
+
obj?.set_payee(t, pst);
|
|
333
|
+
}
|
|
334
|
+
if (this.data?.gen_discount !== undefined) {
|
|
335
|
+
const add: WowokDiscountDispatch[] = [];
|
|
336
|
+
for (let i = 0; i < this.data.gen_discount.length; ++ i) {
|
|
337
|
+
let v = this.data.gen_discount[i];
|
|
338
|
+
const addr = await GetAccountOrMark_Address(v.receiver);
|
|
339
|
+
if (addr) {
|
|
340
|
+
add.push({receiver:addr, count:v.count ?? 1, discount:v.discount})
|
|
308
341
|
}
|
|
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
342
|
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
343
|
+
obj?.discount_transfer(add, pst)
|
|
344
|
+
}
|
|
345
|
+
if (this.data?.repository !== undefined) {
|
|
346
|
+
switch (this.data.repository.op) {
|
|
347
|
+
case 'add':
|
|
348
|
+
case 'set':
|
|
349
|
+
if (this.data.repository.op === 'set') obj?.remove_repository([], true, pst);
|
|
350
|
+
for (let i = 0; i < this.data.repository.objects.length; ++ i) {
|
|
351
|
+
let v = this.data.repository.objects[i];
|
|
352
|
+
const addr = await LocalMark.Instance().get_address(v);
|
|
353
|
+
if (addr) {
|
|
354
|
+
obj?.add_repository(addr, pst)
|
|
355
|
+
}
|
|
322
356
|
}
|
|
323
|
-
|
|
324
|
-
|
|
357
|
+
break;
|
|
358
|
+
case 'remove':
|
|
359
|
+
obj?.remove_repository(await LocalMark.Instance().get_many_address2(this.data.repository.objects), false, pst)
|
|
360
|
+
break;
|
|
361
|
+
case 'removeall':
|
|
362
|
+
obj?.remove_repository([], true, pst)
|
|
363
|
+
break;
|
|
325
364
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
}
|
|
365
|
+
}
|
|
366
|
+
if (this.data?.extern_withdraw_treasury !== undefined) {
|
|
367
|
+
switch(this.data.extern_withdraw_treasury.op) {
|
|
368
|
+
case 'add':
|
|
369
|
+
case 'set':
|
|
370
|
+
if (this.data.extern_withdraw_treasury.op === 'set') obj?.remove_treasury([], true, pst);
|
|
371
|
+
const r = await query_objects({objects:this.data.extern_withdraw_treasury.objects, no_cache:true});
|
|
372
|
+
r.objects?.forEach(v => {
|
|
373
|
+
if (v.type ==='Treasury') {
|
|
374
|
+
obj?.add_treasury(v.object, Treasury.parseObjectType(v.type_raw), pst)
|
|
337
375
|
}
|
|
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
|
-
}
|
|
376
|
+
});
|
|
377
|
+
break;
|
|
378
|
+
case 'remove':
|
|
379
|
+
obj?.remove_treasury(await LocalMark.Instance().get_many_address2(this.data.extern_withdraw_treasury.objects), false, pst)
|
|
380
|
+
break;
|
|
381
|
+
case 'removeall':
|
|
382
|
+
obj?.remove_treasury([], false, pst)
|
|
383
|
+
break;
|
|
366
384
|
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
385
|
+
}
|
|
386
|
+
if (this.data?.machine !== undefined) {
|
|
387
|
+
const machine = await LocalMark.Instance().get_address(this.data.machine);
|
|
388
|
+
obj?.set_machine(machine, pst)
|
|
389
|
+
}
|
|
390
|
+
if (this.data?.arbitration !== undefined) {
|
|
391
|
+
switch(this.data.arbitration.op) {
|
|
392
|
+
case 'add':
|
|
393
|
+
case 'set':
|
|
394
|
+
if (this.data.arbitration.op === 'set') obj?.remove_arbitration([], true, pst);
|
|
395
|
+
const r = await query_objects({objects:this.data.arbitration.objects, no_cache:true});
|
|
396
|
+
r.objects?.forEach(v => {
|
|
397
|
+
if (v.type ==='Arbitration') {
|
|
398
|
+
obj?.add_arbitration(v.object, Arbitration.parseObjectType(v.type_raw), pst)
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
break;
|
|
402
|
+
case 'remove':
|
|
403
|
+
obj?.remove_arbitration(await LocalMark.Instance().get_many_address2(this.data.arbitration.objects), false, pst)
|
|
404
|
+
break;
|
|
405
|
+
case 'removeall':
|
|
406
|
+
obj?.remove_arbitration([], false, pst)
|
|
407
|
+
break;
|
|
390
408
|
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
409
|
+
}
|
|
410
|
+
if (this.data?.customer_required_info !== undefined) {
|
|
411
|
+
if (this.data.customer_required_info.required_info.length > 0 && this.data.customer_required_info.pubkey) {
|
|
412
|
+
obj?.set_customer_required(this.data.customer_required_info.pubkey, this.data.customer_required_info.required_info, pst);
|
|
413
|
+
} else if (this.data.customer_required_info.pubkey) {
|
|
414
|
+
obj?.change_required_pubkey(this.data.customer_required_info.pubkey, pst);
|
|
397
415
|
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
416
|
+
}
|
|
417
|
+
if (this.data?.sales !== undefined) {
|
|
418
|
+
switch(this.data.sales.op) {
|
|
419
|
+
case 'add':
|
|
420
|
+
obj?.add_sales(this.data.sales.sales, false, pst)
|
|
421
|
+
break;
|
|
422
|
+
case 'remove':
|
|
423
|
+
obj?.remove_sales(this.data.sales.sales_name, pst)
|
|
424
|
+
break;
|
|
407
425
|
}
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
426
|
+
}
|
|
427
|
+
if (this.data?.withdraw_guard !== undefined) {
|
|
428
|
+
switch(this.data.withdraw_guard.op) {
|
|
429
|
+
case 'add':
|
|
430
|
+
case 'set':
|
|
431
|
+
if (this.data.withdraw_guard.op === 'set') obj?.remove_withdraw_guards([], true, pst);
|
|
413
432
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
}
|
|
433
|
+
const add = []
|
|
434
|
+
for (let i = 0; i < this.data.withdraw_guard.guards.length; ++ i) {
|
|
435
|
+
let v = this.data.withdraw_guard.guards[i];
|
|
436
|
+
const addr = typeof(v.guard) === 'string' ? await LocalMark.Instance().get_address(v.guard as string) : v.guard;
|
|
437
|
+
if (addr) {
|
|
438
|
+
v.guard = addr;
|
|
439
|
+
add.push(v)
|
|
422
440
|
}
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
441
|
+
}
|
|
442
|
+
obj?.add_withdraw_guards(add, pst)
|
|
443
|
+
break;
|
|
444
|
+
case 'remove':
|
|
445
|
+
obj?.remove_withdraw_guards(await LocalMark.Instance().get_many_address2(this.data.withdraw_guard.guards), false, pst)
|
|
446
|
+
break;
|
|
447
|
+
case 'removeall':
|
|
448
|
+
obj?.remove_withdraw_guards([], true, pst)
|
|
449
|
+
break;
|
|
432
450
|
}
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
451
|
+
}
|
|
452
|
+
if (this.data?.refund_guard !== undefined) {
|
|
453
|
+
switch(this.data.refund_guard.op) {
|
|
454
|
+
case 'add':
|
|
455
|
+
case 'set':
|
|
456
|
+
if (this.data.refund_guard.op === 'set') obj?.remove_refund_guards([], true, pst);
|
|
457
|
+
const add = []
|
|
458
|
+
for (let i = 0; i < this.data.refund_guard.guards.length; ++ i) {
|
|
459
|
+
let v = this.data.refund_guard.guards[i];
|
|
460
|
+
const addr = typeof(v.guard) === 'string' ? await LocalMark.Instance().get_address(v.guard as string) : v.guard;
|
|
461
|
+
if (addr) {
|
|
462
|
+
v.guard = addr;
|
|
463
|
+
add.push(v)
|
|
446
464
|
}
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
}
|
|
458
|
-
if (this.data?.bPublished) {
|
|
459
|
-
obj?.publish(pst)
|
|
465
|
+
}
|
|
466
|
+
obj?.add_refund_guards(add, pst)
|
|
467
|
+
break;
|
|
468
|
+
|
|
469
|
+
case 'remove':
|
|
470
|
+
obj?.remove_refund_guards(await LocalMark.Instance().get_many_address2(this.data.refund_guard.guards), false, pst)
|
|
471
|
+
break;
|
|
472
|
+
case 'removeall':
|
|
473
|
+
obj?.remove_refund_guards([], true, pst)
|
|
474
|
+
break;
|
|
460
475
|
}
|
|
476
|
+
}
|
|
477
|
+
if (this.data?.bPublished) {
|
|
478
|
+
obj?.publish(pst)
|
|
479
|
+
}
|
|
461
480
|
|
|
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
|
-
}
|
|
481
|
+
if (this.data?.buy_guard !== undefined) {
|
|
482
|
+
obj?.set_buy_guard(this.data.buy_guard, pst)
|
|
483
|
+
}
|
|
484
|
+
if (this.data?.bPaused !== undefined) {
|
|
485
|
+
obj?.pause(this.data.bPaused, pst)
|
|
481
486
|
}
|
|
487
|
+
if (this.data?.clone_new !== undefined) {
|
|
488
|
+
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
|
+
}
|
|
490
|
+
if (payee) {
|
|
491
|
+
await this.new_with_mark('Treasury', txb, payee.launch(), GetObjectParam(this.data?.payee_treasury), account);
|
|
492
|
+
}
|
|
493
|
+
if (perm) {
|
|
494
|
+
const n = GetObjectMain(this.data.object) as TypeNamedObjectWithPermission;
|
|
495
|
+
await this.new_with_mark('Permission', txb, perm.launch(), GetObjectParam(n?.permission), account);
|
|
496
|
+
}
|
|
497
|
+
if (!this.object_address) {
|
|
498
|
+
await this.new_with_mark('Service', txb, obj.launch(), GetObjectMain(this.data?.object), account);
|
|
499
|
+
}
|
|
482
500
|
}
|
|
483
501
|
|
|
484
502
|
private info_crypto = async (object?:string, info?: string) : Promise<Customer_RequiredInfo | undefined>=> {
|