wowok_agent 0.0.1 → 0.1.3
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/README.md +3 -3
- package/package.json +1 -1
- package/src/account.ts +26 -4
- package/src/call/arbitration.ts +87 -72
- package/src/call/{call.ts → base.ts} +37 -36
- package/src/call/demand.ts +73 -59
- package/src/call/guard.ts +264 -0
- package/src/call/machine.ts +85 -77
- package/src/call/permission.ts +42 -34
- package/src/call/personal.ts +38 -30
- package/src/call/repository.ts +52 -43
- package/src/call/service.ts +140 -126
- package/src/call/treasury.ts +76 -60
- package/src/call.ts +70 -0
- package/src/index.ts +3 -1
- package/src/objects.ts +338 -338
- package/src/permission.ts +33 -34
package/src/call/repository.ts
CHANGED
|
@@ -3,125 +3,134 @@ import { PassportObject, IsValidAddress, Errors, ERROR, Permission, PermissionIn
|
|
|
3
3
|
Repository_Policy, Repository_Policy_Data, Repository_Policy_Data2, Repository_Policy_Data_Remove,
|
|
4
4
|
Repository_Policy_Mode, WitnessFill
|
|
5
5
|
} from 'wowok';
|
|
6
|
-
import { CallBase } from "./
|
|
6
|
+
import { CallBase, CallResult} from "./base";
|
|
7
7
|
|
|
8
|
-
export
|
|
9
|
-
|
|
8
|
+
export interface CallRepository_Data {
|
|
9
|
+
object?: string; // undefined for creating a new object
|
|
10
|
+
permission?: string;
|
|
11
|
+
permission_new?: string; // change permission
|
|
10
12
|
description?: string;
|
|
11
13
|
mode?: Repository_Policy_Mode; // default: 'Relax' (POLICY_MODE_FREE)
|
|
12
14
|
reference?: {op:'set' | 'add' | 'remove' ; addresses:string[]} | {op:'removeall'};
|
|
13
15
|
policy?: {op:'add' | 'set'; data:Repository_Policy[]} | {op:'remove'; data:string[]} | {op:'removeall'} | {op:'rename'; data:{old:string; new:string}[]};
|
|
14
16
|
data?: {op:'add', data: Repository_Policy_Data | Repository_Policy_Data2} | {op:'remove'; data: Repository_Policy_Data_Remove};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
}
|
|
18
|
+
export class CallRepository extends CallBase {
|
|
19
|
+
data: CallRepository_Data;
|
|
20
|
+
constructor(data:CallRepository_Data) {
|
|
21
|
+
super();
|
|
22
|
+
this.data = data;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async call(account?:string) : Promise<CallResult> {
|
|
17
26
|
var checkOwner = false;
|
|
18
27
|
const perms : PermissionIndexType[] = [];
|
|
19
28
|
|
|
20
|
-
if (this?.permission && IsValidAddress(this.permission)) {
|
|
21
|
-
if (this?.object
|
|
29
|
+
if (this.data?.permission && IsValidAddress(this.data.permission)) {
|
|
30
|
+
if (!this.data?.object) {
|
|
22
31
|
perms.push(PermissionIndex.repository)
|
|
23
32
|
}
|
|
24
|
-
if (this?.permission_new !== undefined) {
|
|
33
|
+
if (this.data?.permission_new !== undefined) {
|
|
25
34
|
checkOwner = true;
|
|
26
35
|
}
|
|
27
|
-
if (this?.description !== undefined && this?.object
|
|
36
|
+
if (this.data?.description !== undefined && this.data?.object) {
|
|
28
37
|
perms.push(PermissionIndex.repository_description)
|
|
29
38
|
}
|
|
30
|
-
if (this?.mode !== undefined && this?.object
|
|
39
|
+
if (this.data?.mode !== undefined && this.data?.object) {
|
|
31
40
|
perms.push(PermissionIndex.repository_mode)
|
|
32
41
|
}
|
|
33
|
-
if (this?.reference !== undefined) {
|
|
42
|
+
if (this.data?.reference !== undefined) {
|
|
34
43
|
perms.push(PermissionIndex.repository_reference)
|
|
35
44
|
}
|
|
36
|
-
if (this?.policy !== undefined) {
|
|
45
|
+
if (this.data?.policy !== undefined) {
|
|
37
46
|
perms.push(PermissionIndex.repository_policies)
|
|
38
47
|
}
|
|
39
|
-
return await this.check_permission_and_call(this.permission, perms, [], checkOwner, undefined, account)
|
|
48
|
+
return await this.check_permission_and_call(this.data.permission, perms, [], checkOwner, undefined, account)
|
|
40
49
|
}
|
|
41
50
|
return this.exec(account);
|
|
42
51
|
}
|
|
43
52
|
|
|
44
53
|
protected async operate(txb:TransactionBlock, passport?:PassportObject) {
|
|
45
54
|
let obj : Repository | undefined ; let permission: any;
|
|
46
|
-
if (this.object
|
|
47
|
-
if (!this?.permission || !IsValidAddress(this?.permission)) {
|
|
55
|
+
if (!this.data.object) {
|
|
56
|
+
if (!this.data?.permission || !IsValidAddress(this.data?.permission)) {
|
|
48
57
|
permission = Permission.New(txb, '');
|
|
49
58
|
}
|
|
50
59
|
|
|
51
|
-
obj = Repository.New(txb, permission ?? this?.permission, this?.description??'', this?.mode, permission?undefined:passport)
|
|
60
|
+
obj = Repository.New(txb, permission ?? this.data?.permission, this.data?.description??'', this.data?.mode, permission?undefined:passport)
|
|
52
61
|
} else {
|
|
53
|
-
if (IsValidAddress(this.object) && this.permission && IsValidAddress(this?.permission)) {
|
|
54
|
-
obj = Repository.From(txb, this.permission, this.object)
|
|
62
|
+
if (IsValidAddress(this.data.object) && this.data.permission && IsValidAddress(this.data?.permission)) {
|
|
63
|
+
obj = Repository.From(txb, this.data.permission, this.data.object)
|
|
55
64
|
}
|
|
56
65
|
}
|
|
57
66
|
|
|
58
67
|
if (obj) {
|
|
59
|
-
if (this?.description !== undefined && this.object
|
|
60
|
-
obj?.set_description(this.description, passport);
|
|
68
|
+
if (this.data?.description !== undefined && this.data.object) {
|
|
69
|
+
obj?.set_description(this.data.description, passport);
|
|
61
70
|
}
|
|
62
|
-
if (this?.mode !== undefined && this.object
|
|
63
|
-
obj?.set_policy_mode(this.mode, passport)
|
|
71
|
+
if (this.data?.mode !== undefined && this.data.object) {
|
|
72
|
+
obj?.set_policy_mode(this.data.mode, passport)
|
|
64
73
|
}
|
|
65
|
-
if (this?.reference !== undefined) {
|
|
66
|
-
switch (this.reference.op) {
|
|
74
|
+
if (this.data?.reference !== undefined) {
|
|
75
|
+
switch (this.data.reference.op) {
|
|
67
76
|
case 'set':
|
|
68
77
|
obj?.remove_reference([], true, passport);
|
|
69
|
-
obj?.add_reference(this.reference.addresses, passport);
|
|
78
|
+
obj?.add_reference(this.data.reference.addresses, passport);
|
|
70
79
|
break;
|
|
71
80
|
case 'add':
|
|
72
|
-
obj?.add_reference(this.reference.addresses, passport);
|
|
81
|
+
obj?.add_reference(this.data.reference.addresses, passport);
|
|
73
82
|
break;
|
|
74
83
|
case 'remove':
|
|
75
|
-
obj?.remove_reference(this.reference.addresses, false, passport);
|
|
84
|
+
obj?.remove_reference(this.data.reference.addresses, false, passport);
|
|
76
85
|
break;
|
|
77
86
|
case 'removeall':
|
|
78
87
|
obj?.remove_reference([], true, passport);
|
|
79
88
|
break;
|
|
80
89
|
}
|
|
81
90
|
}
|
|
82
|
-
if (this?.policy !== undefined) {
|
|
83
|
-
switch(this.policy.op) {
|
|
91
|
+
if (this.data?.policy !== undefined) {
|
|
92
|
+
switch(this.data.policy.op) {
|
|
84
93
|
case 'set':
|
|
85
94
|
obj?.remove_policies([], true, passport);
|
|
86
|
-
obj?.add_policies(this.policy.data, passport);
|
|
95
|
+
obj?.add_policies(this.data.policy.data, passport);
|
|
87
96
|
break;
|
|
88
97
|
case 'add':
|
|
89
|
-
obj?.add_policies(this.policy.data, passport);
|
|
98
|
+
obj?.add_policies(this.data.policy.data, passport);
|
|
90
99
|
break;
|
|
91
100
|
case 'remove':
|
|
92
|
-
obj?.remove_policies(this.policy.data, false, passport);
|
|
101
|
+
obj?.remove_policies(this.data.policy.data, false, passport);
|
|
93
102
|
break;
|
|
94
103
|
case 'removeall':
|
|
95
104
|
obj?.remove_policies([], true, passport);
|
|
96
105
|
break;
|
|
97
106
|
case 'rename':
|
|
98
|
-
this.policy.data.forEach((v) => {
|
|
107
|
+
this.data.policy.data.forEach((v) => {
|
|
99
108
|
obj?.rename_policy(v.old, v.new, passport);
|
|
100
109
|
})
|
|
101
110
|
break;
|
|
102
111
|
}
|
|
103
112
|
}
|
|
104
|
-
if (this?.data !== undefined) {
|
|
105
|
-
switch(this.data.op) {
|
|
113
|
+
if (this.data?.data !== undefined) {
|
|
114
|
+
switch(this.data.data.op) {
|
|
106
115
|
case 'add':
|
|
107
|
-
if ((this.data?.data as any)?.key !== undefined) {
|
|
108
|
-
obj?.add_data(this.data.data as Repository_Policy_Data);
|
|
109
|
-
} else if ((this.data?.data as any)?.address !== undefined) {
|
|
110
|
-
obj?.add_data2(this.data.data as Repository_Policy_Data2);
|
|
116
|
+
if ((this.data.data?.data as any)?.key !== undefined) {
|
|
117
|
+
obj?.add_data(this.data.data.data as Repository_Policy_Data);
|
|
118
|
+
} else if ((this.data.data?.data as any)?.address !== undefined) {
|
|
119
|
+
obj?.add_data2(this.data.data.data as Repository_Policy_Data2);
|
|
111
120
|
}
|
|
112
121
|
break;
|
|
113
122
|
case 'remove':
|
|
114
|
-
obj?.remove(this.data.data.address, this.data.data.key);
|
|
123
|
+
obj?.remove(this.data.data.data.address, this.data.data.data.key);
|
|
115
124
|
break;
|
|
116
125
|
}
|
|
117
126
|
}
|
|
118
|
-
if (this?.permission_new !== undefined ) {
|
|
119
|
-
obj?.change_permission(this.permission_new);
|
|
127
|
+
if (this.data?.permission_new !== undefined ) {
|
|
128
|
+
obj?.change_permission(this.data.permission_new);
|
|
120
129
|
}
|
|
121
130
|
if (permission) {
|
|
122
131
|
permission.launch();
|
|
123
132
|
}
|
|
124
|
-
if (this.object
|
|
133
|
+
if (!this.data.object) {
|
|
125
134
|
obj?.launch();
|
|
126
135
|
}
|
|
127
136
|
}
|
package/src/call/service.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { TransactionBlock, CallResponse} from 'wowok';
|
|
1
|
+
import { TransactionBlock, CallResponse, IsValidArgType} from 'wowok';
|
|
2
2
|
import { PassportObject, IsValidAddress, Errors, ERROR, Permission, PermissionIndex,
|
|
3
3
|
PermissionIndexType, BuyRequiredEnum, Customer_RequiredInfo, DicountDispatch, Service, Service_Buy,
|
|
4
4
|
Service_Guard_Percent, Service_Sale, WithdrawPayee, Treasury, WitnessFill
|
|
5
5
|
} from 'wowok';
|
|
6
|
-
import {
|
|
7
|
-
import { CallBase } from "./
|
|
6
|
+
import { query_objects, ObjectService } from '../objects';
|
|
7
|
+
import { CallBase, CallResult } from "./base";
|
|
8
8
|
|
|
9
|
-
export
|
|
10
|
-
|
|
9
|
+
export interface CallService_Data {
|
|
10
|
+
object?: string; // undefined for creating a new object
|
|
11
|
+
permission?: string;
|
|
12
|
+
type_parameter?: string;
|
|
11
13
|
permission_new?: string;
|
|
12
14
|
bPaused?: boolean;
|
|
13
15
|
bPublished?: boolean;
|
|
@@ -35,234 +37,246 @@ export class CallService extends CallBase {
|
|
|
35
37
|
order_withdrawl?: {order:string; data:WithdrawPayee}; // guard address
|
|
36
38
|
order_payer?: {order:string; payer_new: string}; // transfer the order payer permission to someaddress
|
|
37
39
|
order_agent?: {order:string; agents: string[]; progress?:string};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
}
|
|
41
|
+
export class CallService extends CallBase {
|
|
42
|
+
data: CallService_Data;
|
|
43
|
+
constructor(data: CallService_Data) {
|
|
44
|
+
super();
|
|
45
|
+
this.data = data;
|
|
41
46
|
}
|
|
42
|
-
async call(account?:string) : Promise<
|
|
43
|
-
if (!this.type_parameter
|
|
47
|
+
async call(account?:string) : Promise<CallResult> {
|
|
48
|
+
if (!this.data.type_parameter || !IsValidArgType(this.data.type_parameter)) {
|
|
49
|
+
ERROR(Errors.IsValidArgType, 'service.type_parameter');
|
|
50
|
+
}
|
|
44
51
|
|
|
45
52
|
var checkOwner = false; const guards : string[] = [];
|
|
46
53
|
const perms : PermissionIndexType[] = []; var obj: ObjectService | undefined;
|
|
47
54
|
|
|
48
|
-
if (this?.permission && IsValidAddress(this.permission)) {
|
|
49
|
-
if (this?.object
|
|
55
|
+
if (this.data?.permission && IsValidAddress(this.data.permission)) {
|
|
56
|
+
if (!this.data?.object) {
|
|
50
57
|
perms.push(PermissionIndex.service)
|
|
51
58
|
}
|
|
52
|
-
if (this?.permission_new !== undefined) {
|
|
59
|
+
if (this.data?.permission_new !== undefined) {
|
|
53
60
|
checkOwner = true;
|
|
54
61
|
}
|
|
55
|
-
if (this?.description !== undefined && this.object
|
|
62
|
+
if (this.data?.description !== undefined && this.data.object) {
|
|
56
63
|
perms.push(PermissionIndex.service_description)
|
|
57
64
|
}
|
|
58
|
-
if (this?.bPaused !== undefined) {
|
|
65
|
+
if (this.data?.bPaused !== undefined) {
|
|
59
66
|
perms.push(PermissionIndex.service_pause)
|
|
60
67
|
}
|
|
61
|
-
if (this?.bPublished) { // publish is an irreversible one-time operation
|
|
68
|
+
if (this.data?.bPublished) { // publish is an irreversible one-time operation
|
|
62
69
|
perms.push(PermissionIndex.service_publish)
|
|
63
70
|
}
|
|
64
|
-
if (this?.endpoint !== undefined) {
|
|
71
|
+
if (this.data?.endpoint !== undefined) {
|
|
65
72
|
perms.push(PermissionIndex.service_endpoint)
|
|
66
73
|
}
|
|
67
|
-
if (this?.repository !== undefined) {
|
|
74
|
+
if (this.data?.repository !== undefined) {
|
|
68
75
|
perms.push(PermissionIndex.service_repository)
|
|
69
76
|
}
|
|
70
|
-
if (this?.clone_new !== undefined) {
|
|
77
|
+
if (this.data?.clone_new !== undefined) {
|
|
71
78
|
perms.push(PermissionIndex.service_clone)
|
|
72
79
|
}
|
|
73
|
-
if (this?.gen_discount !== undefined) {
|
|
80
|
+
if (this.data?.gen_discount !== undefined) {
|
|
74
81
|
perms.push(PermissionIndex.service_discount_transfer)
|
|
75
82
|
}
|
|
76
|
-
if (this?.arbitration !== undefined) {
|
|
83
|
+
if (this.data?.arbitration !== undefined) {
|
|
77
84
|
perms.push(PermissionIndex.service_arbitration)
|
|
78
85
|
}
|
|
79
|
-
if (this?.buy_guard !== undefined) {
|
|
86
|
+
if (this.data?.buy_guard !== undefined) {
|
|
80
87
|
perms.push(PermissionIndex.service_buyer_guard)
|
|
81
88
|
}
|
|
82
|
-
if (this?.endpoint !== undefined) {
|
|
89
|
+
if (this.data?.endpoint !== undefined) {
|
|
83
90
|
perms.push(PermissionIndex.service_endpoint)
|
|
84
91
|
}
|
|
85
|
-
if (this?.extern_withdraw_treasury !== undefined) {
|
|
92
|
+
if (this.data?.extern_withdraw_treasury !== undefined) {
|
|
86
93
|
perms.push(PermissionIndex.service_treasury)
|
|
87
94
|
}
|
|
88
|
-
if (this?.machine !== undefined) {
|
|
95
|
+
if (this.data?.machine !== undefined) {
|
|
89
96
|
perms.push(PermissionIndex.service_machine)
|
|
90
97
|
}
|
|
91
|
-
if (this?.payee_treasury !== undefined && this.object
|
|
98
|
+
if (this.data?.payee_treasury !== undefined && this.data.object) {
|
|
92
99
|
perms.push(PermissionIndex.service_payee)
|
|
93
100
|
}
|
|
94
|
-
if (this?.withdraw_guard !== undefined) {
|
|
101
|
+
if (this.data?.withdraw_guard !== undefined) {
|
|
95
102
|
perms.push(PermissionIndex.service_withdraw_guards)
|
|
96
103
|
}
|
|
97
|
-
if (this?.refund_guard !== undefined) {
|
|
104
|
+
if (this.data?.refund_guard !== undefined) {
|
|
98
105
|
perms.push(PermissionIndex.service_refund_guards)
|
|
99
106
|
}
|
|
100
|
-
if (this?.customer_required_info !== undefined) {
|
|
107
|
+
if (this.data?.customer_required_info !== undefined) {
|
|
101
108
|
perms.push(PermissionIndex.service_customer_required)
|
|
102
109
|
}
|
|
103
|
-
if (this?.sales !== undefined) {
|
|
110
|
+
if (this.data?.sales !== undefined) {
|
|
104
111
|
perms.push(PermissionIndex.service_sales)
|
|
105
112
|
}
|
|
106
|
-
if (this?.order_new?.guard !== undefined) {
|
|
107
|
-
if (IsValidAddress(this.order_new.guard)) {
|
|
108
|
-
guards.push(this.order_new.guard)
|
|
109
|
-
} else
|
|
110
|
-
if (!
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
113
|
+
if (this.data?.order_new?.guard !== undefined) {
|
|
114
|
+
if (IsValidAddress(this.data.order_new.guard)) {
|
|
115
|
+
guards.push(this.data.order_new.guard)
|
|
116
|
+
} else {
|
|
117
|
+
if (!this.data.object) {
|
|
118
|
+
if (this.data?.buy_guard && IsValidAddress(this.data.buy_guard)) {
|
|
119
|
+
guards.push(this.data?.buy_guard)
|
|
120
|
+
}
|
|
121
|
+
} else {
|
|
122
|
+
if (!obj) {
|
|
123
|
+
const r = await query_objects({objects:[this.data.object], showContent:true});
|
|
124
|
+
if (r?.objects && r.objects[0].type === 'Service') {
|
|
125
|
+
obj = r.objects[0] as ObjectService;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (obj?.buy_guard) {
|
|
129
|
+
guards.push(obj?.buy_guard)
|
|
114
130
|
}
|
|
115
131
|
}
|
|
116
|
-
if (obj?.buy_guard) {
|
|
117
|
-
guards.push(obj?.buy_guard)
|
|
118
|
-
}
|
|
119
132
|
}
|
|
120
133
|
}
|
|
121
|
-
if (IsValidAddress((this?.order_refund as any)?.guard)) {
|
|
122
|
-
guards.push((this?.order_refund as any)?.guard)
|
|
134
|
+
if (IsValidAddress((this.data?.order_refund as any)?.guard)) {
|
|
135
|
+
guards.push((this.data?.order_refund as any)?.guard)
|
|
123
136
|
}
|
|
124
|
-
if (this.order_withdrawl !== undefined) { // permission(may be guard) + withdraw_guard
|
|
137
|
+
if (this.data.order_withdrawl !== undefined) { // permission(may be guard) + withdraw_guard
|
|
125
138
|
perms.push(PermissionIndex.service_withdraw)
|
|
126
139
|
}
|
|
127
140
|
|
|
128
|
-
if (typeof(this?.order_withdrawl?.data?.withdraw_guard) === 'string' && IsValidAddress(this?.order_withdrawl?.data?.withdraw_guard)) {
|
|
129
|
-
guards.push(this?.order_withdrawl?.data?.withdraw_guard)
|
|
141
|
+
if (typeof(this.data?.order_withdrawl?.data?.withdraw_guard) === 'string' && IsValidAddress(this.data?.order_withdrawl?.data?.withdraw_guard)) {
|
|
142
|
+
guards.push(this.data?.order_withdrawl?.data?.withdraw_guard)
|
|
130
143
|
}
|
|
131
144
|
|
|
132
|
-
return await this.check_permission_and_call(this.permission, perms, guards, checkOwner, undefined, account)
|
|
145
|
+
return await this.check_permission_and_call(this.data.permission, perms, guards, checkOwner, undefined, account)
|
|
133
146
|
}
|
|
134
147
|
return this.exec(account);
|
|
135
148
|
}
|
|
136
149
|
protected async operate (txb:TransactionBlock, passport?:PassportObject) {
|
|
137
150
|
let obj : Service | undefined ; let permission: any; let payee: any;
|
|
138
|
-
|
|
139
|
-
|
|
151
|
+
|
|
152
|
+
if (!this.data.object) {
|
|
153
|
+
if (!this.data?.permission || !IsValidAddress(this.data?.permission)) {
|
|
140
154
|
permission = Permission.New(txb, '');
|
|
141
155
|
}
|
|
142
|
-
if (!this?.payee_treasury || !IsValidAddress(this?.payee_treasury)) {
|
|
143
|
-
payee = Treasury.New(txb, this?.type_parameter
|
|
156
|
+
if (!this.data?.payee_treasury || !IsValidAddress(this.data?.payee_treasury)) {
|
|
157
|
+
payee = Treasury.New(txb, this.data?.type_parameter!, permission ?? this.data?.permission, '', permission?undefined:passport);
|
|
144
158
|
}
|
|
145
|
-
obj = Service.New(txb, this.type_parameter
|
|
159
|
+
obj = Service.New(txb, this.data.type_parameter!, permission??this.data?.permission, this.data?.description??'', payee??this.data?.payee_treasury, permission?undefined:passport)
|
|
146
160
|
} else {
|
|
147
|
-
if (IsValidAddress(this.object) && this.type_parameter && this.permission && IsValidAddress(this?.permission)) {
|
|
148
|
-
obj = Service.From(txb, this.type_parameter, this.permission, this.object)
|
|
161
|
+
if (IsValidAddress(this.data.object) && this.data.type_parameter && this.data.permission && IsValidAddress(this.data?.permission)) {
|
|
162
|
+
obj = Service.From(txb, this.data.type_parameter, this.data.permission, this.data.object)
|
|
149
163
|
}
|
|
150
164
|
}
|
|
151
165
|
|
|
152
166
|
if (obj) {
|
|
153
|
-
if (this?.description !== undefined && this.object
|
|
154
|
-
obj?.set_description(this.description, passport);
|
|
167
|
+
if (this.data?.description !== undefined && this.data.object) {
|
|
168
|
+
obj?.set_description(this.data.description, passport);
|
|
155
169
|
}
|
|
156
|
-
if (this?.payee_treasury !== undefined && this.object
|
|
157
|
-
obj?.set_payee(this.payee_treasury, passport);
|
|
170
|
+
if (this.data?.payee_treasury !== undefined && this.data.object) {
|
|
171
|
+
obj?.set_payee(this.data.payee_treasury, passport);
|
|
158
172
|
}
|
|
159
|
-
if (this?.endpoint !== undefined) {
|
|
160
|
-
obj?.set_endpoint(this.endpoint, passport)
|
|
173
|
+
if (this.data?.endpoint !== undefined) {
|
|
174
|
+
obj?.set_endpoint(this.data.endpoint, passport)
|
|
161
175
|
}
|
|
162
|
-
if (this?.buy_guard !== undefined) {
|
|
163
|
-
obj?.set_buy_guard(this.buy_guard, passport)
|
|
176
|
+
if (this.data?.buy_guard !== undefined) {
|
|
177
|
+
obj?.set_buy_guard(this.data.buy_guard, passport)
|
|
164
178
|
}
|
|
165
|
-
if (this?.bPaused !== undefined) {
|
|
166
|
-
obj?.pause(this.bPaused, passport)
|
|
179
|
+
if (this.data?.bPaused !== undefined) {
|
|
180
|
+
obj?.pause(this.data.bPaused, passport)
|
|
167
181
|
}
|
|
168
|
-
if (this?.bPublished) {
|
|
182
|
+
if (this.data?.bPublished) {
|
|
169
183
|
obj?.publish(passport)
|
|
170
184
|
}
|
|
171
|
-
if (this?.clone_new !== undefined) {
|
|
172
|
-
obj?.clone(this.clone_new?.token_type_new, true, passport)
|
|
185
|
+
if (this.data?.clone_new !== undefined) {
|
|
186
|
+
obj?.clone(this.data.clone_new?.token_type_new, true, passport)
|
|
173
187
|
}
|
|
174
|
-
if (this?.machine !== undefined) {
|
|
175
|
-
obj?.set_machine(this.machine, passport)
|
|
188
|
+
if (this.data?.machine !== undefined) {
|
|
189
|
+
obj?.set_machine(this.data.machine, passport)
|
|
176
190
|
}
|
|
177
|
-
if (this?.repository !== undefined) {
|
|
178
|
-
switch (this.repository.op) {
|
|
191
|
+
if (this.data?.repository !== undefined) {
|
|
192
|
+
switch (this.data.repository.op) {
|
|
179
193
|
case 'add':
|
|
180
|
-
this.repository.repositories.forEach(v => obj?.add_repository(v, passport))
|
|
194
|
+
this.data.repository.repositories.forEach(v => obj?.add_repository(v, passport))
|
|
181
195
|
break;
|
|
182
196
|
case 'remove':
|
|
183
|
-
obj?.remove_repository(this.repository.repositories, false, passport)
|
|
197
|
+
obj?.remove_repository(this.data.repository.repositories, false, passport)
|
|
184
198
|
break;
|
|
185
199
|
case 'set':
|
|
186
200
|
obj?.remove_repository([], true, passport)
|
|
187
|
-
this.repository.repositories.forEach(v => obj?.add_repository(v, passport))
|
|
201
|
+
this.data.repository.repositories.forEach(v => obj?.add_repository(v, passport))
|
|
188
202
|
break;
|
|
189
203
|
case 'removeall':
|
|
190
204
|
obj?.remove_repository([], true, passport)
|
|
191
205
|
break;
|
|
192
206
|
}
|
|
193
207
|
}
|
|
194
|
-
if (this?.extern_withdraw_treasury !== undefined) {
|
|
195
|
-
switch(this.extern_withdraw_treasury.op) {
|
|
208
|
+
if (this.data?.extern_withdraw_treasury !== undefined) {
|
|
209
|
+
switch(this.data.extern_withdraw_treasury.op) {
|
|
196
210
|
case 'add':
|
|
197
|
-
this.extern_withdraw_treasury.treasuries.forEach(v=>obj?.add_treasury(v.token_type, v.address, passport))
|
|
211
|
+
this.data.extern_withdraw_treasury.treasuries.forEach(v=>obj?.add_treasury(v.token_type, v.address, passport))
|
|
198
212
|
break;
|
|
199
213
|
case 'set':
|
|
200
214
|
obj?.remove_treasury([], true, passport)
|
|
201
|
-
this.extern_withdraw_treasury.treasuries.forEach(v=>obj?.add_treasury(v.token_type, v.address, passport))
|
|
215
|
+
this.data.extern_withdraw_treasury.treasuries.forEach(v=>obj?.add_treasury(v.token_type, v.address, passport))
|
|
202
216
|
break;
|
|
203
217
|
case 'remove':
|
|
204
|
-
obj?.remove_treasury(this.extern_withdraw_treasury.addresses, false, passport)
|
|
218
|
+
obj?.remove_treasury(this.data.extern_withdraw_treasury.addresses, false, passport)
|
|
205
219
|
break;
|
|
206
220
|
case 'removeall':
|
|
207
221
|
obj?.remove_treasury([], false, passport)
|
|
208
222
|
break;
|
|
209
223
|
}
|
|
210
224
|
}
|
|
211
|
-
if (this?.arbitration !== undefined) {
|
|
212
|
-
switch(this.arbitration.op) {
|
|
225
|
+
if (this.data?.arbitration !== undefined) {
|
|
226
|
+
switch(this.data.arbitration.op) {
|
|
213
227
|
case 'add':
|
|
214
|
-
this.arbitration.arbitrations.forEach(v=>obj?.add_arbitration(v.address, v.token_type, passport))
|
|
228
|
+
this.data.arbitration.arbitrations.forEach(v=>obj?.add_arbitration(v.address, v.token_type, passport))
|
|
215
229
|
break;
|
|
216
230
|
case 'set':
|
|
217
231
|
obj?.remove_arbitration([], true, passport)
|
|
218
|
-
this.arbitration.arbitrations.forEach(v=>obj?.add_arbitration(v.address, v.token_type, passport))
|
|
232
|
+
this.data.arbitration.arbitrations.forEach(v=>obj?.add_arbitration(v.address, v.token_type, passport))
|
|
219
233
|
break;
|
|
220
234
|
case 'remove':
|
|
221
|
-
obj?.remove_arbitration(this.arbitration.addresses, false, passport)
|
|
235
|
+
obj?.remove_arbitration(this.data.arbitration.addresses, false, passport)
|
|
222
236
|
break;
|
|
223
237
|
case 'removeall':
|
|
224
238
|
obj?.remove_arbitration([], false, passport)
|
|
225
239
|
break;
|
|
226
240
|
}
|
|
227
241
|
}
|
|
228
|
-
if (this?.customer_required_info !== undefined) {
|
|
229
|
-
if (this.customer_required_info.required_info && this.customer_required_info.pubkey) {
|
|
230
|
-
obj?.set_customer_required(this.customer_required_info.pubkey, this.customer_required_info.required_info, passport);
|
|
231
|
-
} else if (this.customer_required_info.pubkey) {
|
|
232
|
-
obj?.change_required_pubkey(this.customer_required_info.pubkey, passport);
|
|
242
|
+
if (this.data?.customer_required_info !== undefined) {
|
|
243
|
+
if (this.data.customer_required_info.required_info && this.data.customer_required_info.pubkey) {
|
|
244
|
+
obj?.set_customer_required(this.data.customer_required_info.pubkey, this.data.customer_required_info.required_info, passport);
|
|
245
|
+
} else if (this.data.customer_required_info.pubkey) {
|
|
246
|
+
obj?.change_required_pubkey(this.data.customer_required_info.pubkey, passport);
|
|
233
247
|
}
|
|
234
248
|
}
|
|
235
|
-
if (this?.refund_guard !== undefined) {
|
|
236
|
-
switch(this.refund_guard.op) {
|
|
249
|
+
if (this.data?.refund_guard !== undefined) {
|
|
250
|
+
switch(this.data.refund_guard.op) {
|
|
237
251
|
case 'add':
|
|
238
|
-
obj?.add_refund_guards(this.refund_guard.guards, passport)
|
|
252
|
+
obj?.add_refund_guards(this.data.refund_guard.guards, passport)
|
|
239
253
|
break;
|
|
240
254
|
case 'set':
|
|
241
255
|
obj?.remove_refund_guards([], true, passport)
|
|
242
|
-
obj?.add_refund_guards(this.refund_guard.guards, passport)
|
|
256
|
+
obj?.add_refund_guards(this.data.refund_guard.guards, passport)
|
|
243
257
|
break;
|
|
244
258
|
case 'remove':
|
|
245
|
-
obj?.remove_refund_guards(this.refund_guard.addresses, false, passport)
|
|
259
|
+
obj?.remove_refund_guards(this.data.refund_guard.addresses, false, passport)
|
|
246
260
|
break;
|
|
247
261
|
case 'removeall':
|
|
248
262
|
obj?.remove_refund_guards([], true, passport)
|
|
249
263
|
break;
|
|
250
264
|
}
|
|
251
265
|
}
|
|
252
|
-
if (this?.gen_discount !== undefined) {
|
|
253
|
-
obj?.discount_transfer(this.gen_discount, passport)
|
|
266
|
+
if (this.data?.gen_discount !== undefined) {
|
|
267
|
+
obj?.discount_transfer(this.data.gen_discount, passport)
|
|
254
268
|
}
|
|
255
|
-
if (this?.withdraw_guard !== undefined) {
|
|
256
|
-
switch(this.withdraw_guard.op) {
|
|
269
|
+
if (this.data?.withdraw_guard !== undefined) {
|
|
270
|
+
switch(this.data.withdraw_guard.op) {
|
|
257
271
|
case 'add':
|
|
258
|
-
obj?.add_withdraw_guards(this.withdraw_guard.guards, passport)
|
|
272
|
+
obj?.add_withdraw_guards(this.data.withdraw_guard.guards, passport)
|
|
259
273
|
break;
|
|
260
274
|
case 'set':
|
|
261
275
|
obj?.remove_withdraw_guards([], true, passport)
|
|
262
|
-
obj?.add_withdraw_guards(this.withdraw_guard.guards, passport)
|
|
276
|
+
obj?.add_withdraw_guards(this.data.withdraw_guard.guards, passport)
|
|
263
277
|
break;
|
|
264
278
|
case 'remove':
|
|
265
|
-
obj?.remove_withdraw_guards(this.withdraw_guard.addresses, false, passport)
|
|
279
|
+
obj?.remove_withdraw_guards(this.data.withdraw_guard.addresses, false, passport)
|
|
266
280
|
break;
|
|
267
281
|
case 'removeall':
|
|
268
282
|
obj?.remove_withdraw_guards([], true, passport)
|
|
@@ -270,55 +284,55 @@ export class CallService extends CallBase {
|
|
|
270
284
|
}
|
|
271
285
|
}
|
|
272
286
|
|
|
273
|
-
if (this?.sales !== undefined) {
|
|
274
|
-
switch(this.sales.op) {
|
|
287
|
+
if (this.data?.sales !== undefined) {
|
|
288
|
+
switch(this.data.sales.op) {
|
|
275
289
|
case 'add':
|
|
276
|
-
obj?.add_sales(this.sales.sales, false, passport)
|
|
290
|
+
obj?.add_sales(this.data.sales.sales, false, passport)
|
|
277
291
|
break;
|
|
278
292
|
case 'remove':
|
|
279
|
-
obj?.remove_sales(this.sales.sales_name, passport)
|
|
293
|
+
obj?.remove_sales(this.data.sales.sales_name, passport)
|
|
280
294
|
break;
|
|
281
295
|
}
|
|
282
296
|
}
|
|
283
|
-
if (this?.order_new !== undefined) {
|
|
297
|
+
if (this.data?.order_new !== undefined) {
|
|
284
298
|
let b = BigInt(0); let coin : any;
|
|
285
|
-
this.order_new.buy_items.forEach(v => {
|
|
299
|
+
this.data.order_new.buy_items.forEach(v => {
|
|
286
300
|
b += BigInt(v.max_price) * BigInt(v.count)
|
|
287
301
|
})
|
|
288
302
|
if (b > BigInt(0)) {
|
|
289
|
-
if (this?.type_parameter === '0x2::sui::SUI' || this?.type_parameter === '0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI') {
|
|
303
|
+
if (this.data?.type_parameter === '0x2::sui::SUI' || this.data?.type_parameter === '0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI') {
|
|
290
304
|
coin = txb.splitCoins(txb.gas, [b])[0];
|
|
291
|
-
} else if (this?.order_new.coin_object) {
|
|
292
|
-
coin = txb.splitCoins(this.order_new.coin_object, [b])[0];
|
|
305
|
+
} else if (this.data?.order_new.coin_object) {
|
|
306
|
+
coin = txb.splitCoins(this.data.order_new.coin_object, [b])[0];
|
|
293
307
|
}
|
|
294
308
|
}
|
|
295
309
|
|
|
296
310
|
if (coin) {
|
|
297
311
|
//@ crypto tools support
|
|
298
|
-
obj?.buy(this.order_new.buy_items, coin, this.order_new.discount, this.order_new.machine, this.order_new.customer_info_crypto, passport)
|
|
312
|
+
obj?.buy(this.data.order_new.buy_items, coin, this.data.order_new.discount, this.data.order_new.machine, this.data.order_new.customer_info_crypto, passport)
|
|
299
313
|
}
|
|
300
314
|
}
|
|
301
|
-
if (this?.order_payer !== undefined && obj) {
|
|
302
|
-
obj?.change_order_payer(this?.order_payer.order, this.order_payer.payer_new)
|
|
315
|
+
if (this.data?.order_payer !== undefined && obj) {
|
|
316
|
+
obj?.change_order_payer(this.data?.order_payer.order, this.data.order_payer.payer_new)
|
|
303
317
|
}
|
|
304
|
-
if (this?.order_agent !== undefined) {
|
|
305
|
-
obj?.set_order_agent(this.order_agent.order, this.order_agent.agents, this.order_agent.progress)
|
|
318
|
+
if (this.data?.order_agent !== undefined) {
|
|
319
|
+
obj?.set_order_agent(this.data.order_agent.order, this.data.order_agent.agents, this.data.order_agent.progress)
|
|
306
320
|
}
|
|
307
|
-
if (this?.order_required_info !== undefined) {
|
|
308
|
-
obj?.update_order_required_info(this.order_required_info.order, this.order_required_info.info)
|
|
321
|
+
if (this.data?.order_required_info !== undefined) {
|
|
322
|
+
obj?.update_order_required_info(this.data.order_required_info.order, this.data.order_required_info.info)
|
|
309
323
|
}
|
|
310
|
-
if (this?.order_refund !== undefined) {
|
|
311
|
-
if ((this?.order_refund as any)?.arb && (this?.order_refund as any)?.arb_token_type) {
|
|
312
|
-
obj?.refund_withArb(this.order_refund.order, (this?.order_refund as any)?.arb, (this?.order_refund as any)?.arb_token_type)
|
|
324
|
+
if (this.data?.order_refund !== undefined) {
|
|
325
|
+
if ((this.data?.order_refund as any)?.arb && (this.data?.order_refund as any)?.arb_token_type) {
|
|
326
|
+
obj?.refund_withArb(this.data.order_refund.order, (this.data?.order_refund as any)?.arb, (this.data?.order_refund as any)?.arb_token_type)
|
|
313
327
|
} else {
|
|
314
|
-
obj?.refund(this.order_refund.order, (this?.order_refund as any)?.guard, passport)
|
|
328
|
+
obj?.refund(this.data.order_refund.order, (this.data?.order_refund as any)?.guard, passport)
|
|
315
329
|
}
|
|
316
330
|
}
|
|
317
|
-
if (this?.order_withdrawl !== undefined && passport) { //@ need withdrawal passport
|
|
318
|
-
obj?.withdraw(this.order_withdrawl.order, this.order_withdrawl.data, passport)
|
|
331
|
+
if (this.data?.order_withdrawl !== undefined && passport) { //@ need withdrawal passport
|
|
332
|
+
obj?.withdraw(this.data.order_withdrawl.order, this.data.order_withdrawl.data, passport)
|
|
319
333
|
}
|
|
320
|
-
if (this?.permission_new !== undefined) {
|
|
321
|
-
obj?.change_permission(this.permission_new);
|
|
334
|
+
if (this.data?.permission_new !== undefined) {
|
|
335
|
+
obj?.change_permission(this.data.permission_new);
|
|
322
336
|
}
|
|
323
337
|
if (permission) {
|
|
324
338
|
permission.launch();
|
|
@@ -326,7 +340,7 @@ export class CallService extends CallBase {
|
|
|
326
340
|
if (payee) {
|
|
327
341
|
payee.launch();
|
|
328
342
|
}
|
|
329
|
-
if (this.object
|
|
343
|
+
if (!this.data.object) {
|
|
330
344
|
obj?.launch();
|
|
331
345
|
}
|
|
332
346
|
}
|