wowok 1.0.3 → 1.0.4
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/LICENSE +201 -0
- package/README.md +17 -0
- package/dist/demand.js +91 -30
- package/dist/guard.js +79 -73
- package/dist/machine.js +130 -65
- package/dist/passport.js +14 -5
- package/dist/permission.js +111 -49
- package/dist/progress.js +74 -30
- package/dist/protocol.js +84 -52
- package/dist/repository.js +138 -50
- package/dist/reward.js +134 -28
- package/dist/service.js +457 -161
- package/dist/util.js +16 -1
- package/dist/vote.js +134 -56
- package/package.json +4 -5
- package/src/address.graphql +0 -0
- package/src/demand.ts +96 -52
- package/src/guard.ts +88 -82
- package/src/machine.ts +126 -81
- package/src/object.graphql +30 -0
- package/src/passport.ts +7 -7
- package/src/permission.ts +110 -59
- package/src/progress.ts +89 -58
- package/src/protocol.ts +80 -33
- package/src/repository.ts +146 -70
- package/src/reward.ts +131 -45
- package/src/service.ts +433 -209
- package/src/util.ts +16 -1
- package/src/vote.ts +141 -74
package/dist/service.js
CHANGED
|
@@ -1,180 +1,250 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.change_permission = exports.order_bind_service_machine = exports.buy = exports.update_order_required_info = exports.customer_refund = exports.service_pause = exports.service_change_order_required_pubkey = exports.service_change_required_pubkey = exports.service_remove_customer_required = exports.service_set_customer_required = exports.service_clone = exports.service_publish = exports.service_set_endpoint = exports.service_set_machine = exports.service_set_buy_guard = exports.service_withdraw = exports.service_discount_transfer = exports.
|
|
3
|
+
exports.change_permission = exports.order_bind_service_machine = exports.buy = exports.update_order_required_info = exports.customer_refund = exports.service_pause = exports.service_change_order_required_pubkey = exports.service_change_required_pubkey = exports.service_remove_customer_required = exports.service_set_customer_required = exports.BuyRequiredEnum = exports.service_clone = exports.service_publish = exports.service_set_endpoint = exports.service_set_machine = exports.service_set_buy_guard = exports.service_withdraw = exports.service_discount_transfer = exports.Service_Discount_Type = exports.service_remove_sales = exports.service_add_sale = exports.service_remove_refund_guards = exports.service_add_refund_guards = exports.service_remove_withdraw_guards = exports.service_add_withdraw_guards = exports.service_repository_remove = exports.service_repository_add = exports.service_set_payee = exports.service_reduce_stock = exports.service_add_stock = exports.service_set_stock = exports.service_set_price = exports.service_set_description = exports.destroy = exports.launch = exports.service = void 0;
|
|
4
4
|
const bcs_1 = require("@mysten/bcs");
|
|
5
|
-
const protocol_1 = require("./protocol");
|
|
6
5
|
const util_1 = require("./util");
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
const protocol_1 = require("./protocol");
|
|
7
|
+
function service(pay_type, txb, permission, description, payee_address, endpoint, passport) {
|
|
8
|
+
if (!(0, protocol_1.IsValidObjects)([permission]))
|
|
9
|
+
return false;
|
|
10
|
+
if (!(0, protocol_1.IsValidArgType)(pay_type))
|
|
11
|
+
return false;
|
|
12
|
+
if (!(0, protocol_1.IsValidDesription)(description))
|
|
13
|
+
return false;
|
|
14
|
+
if (!(0, protocol_1.IsValidAddress)(payee_address))
|
|
15
|
+
return false;
|
|
16
|
+
if (endpoint && !(0, protocol_1.IsValidEndpoint)(endpoint))
|
|
17
|
+
return false;
|
|
18
|
+
let ep = endpoint ? txb.pure(util_1.BCS_CONVERT.ser_option_string(endpoint)) : (0, protocol_1.OptionNone)(txb);
|
|
11
19
|
if (passport) {
|
|
12
20
|
return txb.moveCall({
|
|
13
21
|
target: protocol_1.PROTOCOL.ServiceFn('new_with_passport'),
|
|
14
|
-
arguments: [passport, txb.pure(
|
|
22
|
+
arguments: [passport, txb.pure(description), txb.pure(payee_address, bcs_1.BCS.ADDRESS), ep, (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
15
23
|
typeArguments: [pay_type],
|
|
16
24
|
});
|
|
17
25
|
}
|
|
18
26
|
else {
|
|
19
27
|
return txb.moveCall({
|
|
20
28
|
target: protocol_1.PROTOCOL.ServiceFn('new'),
|
|
21
|
-
arguments: [txb.pure(
|
|
29
|
+
arguments: [txb.pure(description), txb.pure(payee_address, bcs_1.BCS.ADDRESS), ep, (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
22
30
|
typeArguments: [pay_type],
|
|
23
31
|
});
|
|
24
32
|
}
|
|
25
33
|
}
|
|
26
34
|
exports.service = service;
|
|
27
35
|
function launch(pay_type, txb, service) {
|
|
36
|
+
if (!(0, protocol_1.IsValidObjects)([service]))
|
|
37
|
+
return false;
|
|
38
|
+
if (!(0, protocol_1.IsValidArgType)(pay_type))
|
|
39
|
+
return false;
|
|
28
40
|
return txb.moveCall({
|
|
29
41
|
target: protocol_1.PROTOCOL.ServiceFn('create'),
|
|
30
|
-
arguments: [service],
|
|
42
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service)],
|
|
31
43
|
typeArguments: [pay_type]
|
|
32
44
|
});
|
|
33
45
|
}
|
|
34
46
|
exports.launch = launch;
|
|
35
47
|
function destroy(pay_type, txb, service) {
|
|
36
|
-
|
|
48
|
+
if (!(0, protocol_1.IsValidObjects)([service]))
|
|
49
|
+
return false;
|
|
50
|
+
if (!(0, protocol_1.IsValidArgType)(pay_type))
|
|
51
|
+
return false;
|
|
52
|
+
txb.moveCall({
|
|
37
53
|
target: protocol_1.PROTOCOL.ServiceFn('destroy'),
|
|
38
|
-
arguments: [service],
|
|
54
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service)],
|
|
39
55
|
typeArguments: [pay_type]
|
|
40
56
|
});
|
|
57
|
+
return true;
|
|
41
58
|
}
|
|
42
59
|
exports.destroy = destroy;
|
|
43
60
|
function service_set_description(pay_type, txb, service, permission, description, passport) {
|
|
61
|
+
if (!(0, protocol_1.IsValidObjects)([service, permission]))
|
|
62
|
+
return false;
|
|
63
|
+
if (!(0, protocol_1.IsValidArgType)(pay_type))
|
|
64
|
+
return false;
|
|
65
|
+
if (!(0, protocol_1.IsValidDesription)(description))
|
|
66
|
+
return false;
|
|
44
67
|
if (passport) {
|
|
45
68
|
txb.moveCall({
|
|
46
69
|
target: protocol_1.PROTOCOL.ServiceFn('description_set_with_passport'),
|
|
47
|
-
arguments: [passport, service, txb.pure((0, protocol_1.
|
|
70
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, service), txb.pure(description), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
48
71
|
typeArguments: [pay_type]
|
|
49
72
|
});
|
|
50
73
|
}
|
|
51
74
|
else {
|
|
52
75
|
txb.moveCall({
|
|
53
76
|
target: protocol_1.PROTOCOL.ServiceFn('description_set'),
|
|
54
|
-
arguments: [service, txb.pure((0, protocol_1.
|
|
77
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), txb.pure(description), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
55
78
|
typeArguments: [pay_type]
|
|
56
79
|
});
|
|
57
80
|
}
|
|
81
|
+
return true;
|
|
58
82
|
}
|
|
59
83
|
exports.service_set_description = service_set_description;
|
|
60
84
|
function service_set_price(pay_type, txb, service, permission, item, price, passport) {
|
|
85
|
+
if (!(0, protocol_1.IsValidObjects)([service, permission]))
|
|
86
|
+
return false;
|
|
87
|
+
if (!(0, protocol_1.IsValidArgType)(pay_type))
|
|
88
|
+
return false;
|
|
89
|
+
if (!(0, protocol_1.IsValidInt)(price) || !(0, protocol_1.IsValidName)(item))
|
|
90
|
+
return false;
|
|
61
91
|
if (passport) {
|
|
62
92
|
txb.moveCall({
|
|
63
93
|
target: protocol_1.PROTOCOL.ServiceFn('price_set_with_passport'),
|
|
64
|
-
arguments: [passport, service, txb.pure(item), txb.pure(price, bcs_1.BCS.U64), permission],
|
|
94
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, service), txb.pure(item), txb.pure(price, bcs_1.BCS.U64), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
65
95
|
typeArguments: [pay_type]
|
|
66
96
|
});
|
|
67
97
|
}
|
|
68
98
|
else {
|
|
69
99
|
txb.moveCall({
|
|
70
100
|
target: protocol_1.PROTOCOL.ServiceFn('price_set'),
|
|
71
|
-
arguments: [service, txb.pure(item), txb.pure(price, bcs_1.BCS.U64), permission],
|
|
101
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), txb.pure(item), txb.pure(price, bcs_1.BCS.U64), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
72
102
|
typeArguments: [pay_type]
|
|
73
103
|
});
|
|
74
104
|
}
|
|
105
|
+
return true;
|
|
75
106
|
}
|
|
76
107
|
exports.service_set_price = service_set_price;
|
|
77
108
|
function service_set_stock(pay_type, txb, service, permission, item, stock, passport) {
|
|
109
|
+
if (!(0, protocol_1.IsValidObjects)([service, permission]))
|
|
110
|
+
return false;
|
|
111
|
+
if (!(0, protocol_1.IsValidArgType)(pay_type))
|
|
112
|
+
return false;
|
|
113
|
+
if (!(0, protocol_1.IsValidName)(item) || !(0, protocol_1.IsValidInt)(stock))
|
|
114
|
+
return false;
|
|
78
115
|
if (passport) {
|
|
79
116
|
txb.moveCall({
|
|
80
117
|
target: protocol_1.PROTOCOL.ServiceFn('stock_set_with_passport'),
|
|
81
|
-
arguments: [passport, service, txb.pure(item), txb.pure(stock, bcs_1.BCS.U64), permission],
|
|
118
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, service), txb.pure(item), txb.pure(stock, bcs_1.BCS.U64), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
82
119
|
typeArguments: [pay_type]
|
|
83
120
|
});
|
|
84
121
|
}
|
|
85
122
|
else {
|
|
86
123
|
txb.moveCall({
|
|
87
124
|
target: protocol_1.PROTOCOL.ServiceFn('stock_set'),
|
|
88
|
-
arguments: [service, txb.pure(item), txb.pure(stock, bcs_1.BCS.U64), permission],
|
|
125
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), txb.pure(item), txb.pure(stock, bcs_1.BCS.U64), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
89
126
|
typeArguments: [pay_type]
|
|
90
127
|
});
|
|
91
128
|
}
|
|
129
|
+
return true;
|
|
92
130
|
}
|
|
93
131
|
exports.service_set_stock = service_set_stock;
|
|
94
132
|
function service_add_stock(pay_type, txb, service, permission, item, stock_add, passport) {
|
|
133
|
+
if (!(0, protocol_1.IsValidObjects)([service, permission]))
|
|
134
|
+
return false;
|
|
135
|
+
if (!(0, protocol_1.IsValidArgType)(pay_type))
|
|
136
|
+
return false;
|
|
137
|
+
if (!(0, protocol_1.IsValidName)(item) || !(0, protocol_1.IsValidUint)(stock_add))
|
|
138
|
+
return false;
|
|
95
139
|
if (passport) {
|
|
96
140
|
txb.moveCall({
|
|
97
141
|
target: protocol_1.PROTOCOL.ServiceFn('stock_add_with_passport'),
|
|
98
|
-
arguments: [passport, service, txb.pure(item), txb.pure(stock_add, bcs_1.BCS.U64), permission],
|
|
142
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, service), txb.pure(item), txb.pure(stock_add, bcs_1.BCS.U64), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
99
143
|
typeArguments: [pay_type]
|
|
100
144
|
});
|
|
101
145
|
}
|
|
102
146
|
else {
|
|
103
147
|
txb.moveCall({
|
|
104
148
|
target: protocol_1.PROTOCOL.ServiceFn('stock_add'),
|
|
105
|
-
arguments: [service, txb.pure(item), txb.pure(stock_add, bcs_1.BCS.U64), permission],
|
|
149
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), txb.pure(item), txb.pure(stock_add, bcs_1.BCS.U64), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
106
150
|
typeArguments: [pay_type]
|
|
107
151
|
});
|
|
108
152
|
}
|
|
153
|
+
return true;
|
|
109
154
|
}
|
|
110
155
|
exports.service_add_stock = service_add_stock;
|
|
111
156
|
function service_reduce_stock(pay_type, txb, service, permission, item, stock_reduce, passport) {
|
|
157
|
+
if (!(0, protocol_1.IsValidObjects)([service, permission]))
|
|
158
|
+
return false;
|
|
159
|
+
if (!(0, protocol_1.IsValidArgType)(pay_type))
|
|
160
|
+
return false;
|
|
161
|
+
if (!(0, protocol_1.IsValidName)(item) || !(0, protocol_1.IsValidUint)(stock_reduce))
|
|
162
|
+
return false;
|
|
112
163
|
if (passport) {
|
|
113
164
|
txb.moveCall({
|
|
114
165
|
target: protocol_1.PROTOCOL.ServiceFn('stock_reduce_with_passport'),
|
|
115
|
-
arguments: [passport, service, txb.pure(item), txb.pure(stock_reduce, bcs_1.BCS.U64), permission],
|
|
166
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, service), txb.pure(item), txb.pure(stock_reduce, bcs_1.BCS.U64), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
116
167
|
typeArguments: [pay_type]
|
|
117
168
|
});
|
|
118
169
|
}
|
|
119
170
|
else {
|
|
120
171
|
txb.moveCall({
|
|
121
172
|
target: protocol_1.PROTOCOL.ServiceFn('stock_reduce'),
|
|
122
|
-
arguments: [service, txb.pure(item), txb.pure(stock_reduce, bcs_1.BCS.U64), permission],
|
|
173
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), txb.pure(item), txb.pure(stock_reduce, bcs_1.BCS.U64), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
123
174
|
typeArguments: [pay_type]
|
|
124
175
|
});
|
|
125
176
|
}
|
|
177
|
+
return true;
|
|
126
178
|
}
|
|
127
179
|
exports.service_reduce_stock = service_reduce_stock;
|
|
128
180
|
function service_set_payee(pay_type, txb, service, permission, payee, passport) {
|
|
181
|
+
if (!(0, protocol_1.IsValidObjects)([service, permission]))
|
|
182
|
+
return false;
|
|
183
|
+
if (!(0, protocol_1.IsValidArgType)(pay_type))
|
|
184
|
+
return false;
|
|
185
|
+
if (!(0, protocol_1.IsValidAddress)(payee))
|
|
186
|
+
return false;
|
|
129
187
|
if (passport) {
|
|
130
188
|
txb.moveCall({
|
|
131
189
|
target: protocol_1.PROTOCOL.ServiceFn('payee_set_with_passport'),
|
|
132
|
-
arguments: [passport, service, txb.pure(payee, bcs_1.BCS.ADDRESS), permission],
|
|
190
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, service), txb.pure(payee, bcs_1.BCS.ADDRESS), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
133
191
|
typeArguments: [pay_type]
|
|
134
192
|
});
|
|
135
193
|
}
|
|
136
194
|
else {
|
|
137
195
|
txb.moveCall({
|
|
138
196
|
target: protocol_1.PROTOCOL.ServiceFn('payee_set'),
|
|
139
|
-
arguments: [service, txb.pure(payee, bcs_1.BCS.ADDRESS), permission],
|
|
197
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), txb.pure(payee, bcs_1.BCS.ADDRESS), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
140
198
|
typeArguments: [pay_type]
|
|
141
199
|
});
|
|
142
200
|
}
|
|
201
|
+
return true;
|
|
143
202
|
}
|
|
144
203
|
exports.service_set_payee = service_set_payee;
|
|
145
204
|
function service_repository_add(pay_type, txb, service, permission, repository, passport) {
|
|
205
|
+
if (!(0, protocol_1.IsValidObjects)([service, permission, repository]))
|
|
206
|
+
return false;
|
|
207
|
+
if (!(0, protocol_1.IsValidArgType)(pay_type))
|
|
208
|
+
return false;
|
|
146
209
|
if (passport) {
|
|
147
210
|
txb.moveCall({
|
|
148
211
|
target: protocol_1.PROTOCOL.ServiceFn('repository_add_with_passport'),
|
|
149
|
-
arguments: [service, repository, permission],
|
|
212
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, repository), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
150
213
|
typeArguments: [pay_type]
|
|
151
214
|
});
|
|
152
215
|
}
|
|
153
216
|
else {
|
|
154
217
|
txb.moveCall({
|
|
155
218
|
target: protocol_1.PROTOCOL.ServiceFn('repository_add'),
|
|
156
|
-
arguments: [service, repository, permission],
|
|
219
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, repository), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
157
220
|
typeArguments: [pay_type]
|
|
158
221
|
});
|
|
159
222
|
}
|
|
223
|
+
return true;
|
|
160
224
|
}
|
|
161
225
|
exports.service_repository_add = service_repository_add;
|
|
162
226
|
function service_repository_remove(pay_type, txb, service, permission, repository_address, removeall, passport) {
|
|
227
|
+
if (!(0, protocol_1.IsValidObjects)([service, permission]))
|
|
228
|
+
return false;
|
|
229
|
+
if (!(0, protocol_1.IsValidArgType)(pay_type))
|
|
230
|
+
return false;
|
|
231
|
+
if (!removeall && !repository_address)
|
|
232
|
+
return false;
|
|
233
|
+
if (repository_address && !(0, protocol_1.IsValidArray)(repository_address, protocol_1.IsValidAddress))
|
|
234
|
+
return false;
|
|
163
235
|
if (passport) {
|
|
164
236
|
if (removeall) {
|
|
165
237
|
txb.moveCall({
|
|
166
238
|
target: protocol_1.PROTOCOL.ServiceFn('repository_remove_all_with_passport'),
|
|
167
|
-
arguments: [passport, service, permission],
|
|
239
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
168
240
|
typeArguments: [pay_type]
|
|
169
241
|
});
|
|
170
242
|
}
|
|
171
243
|
else {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
typeArguments: [pay_type]
|
|
177
|
-
});
|
|
244
|
+
txb.moveCall({
|
|
245
|
+
target: protocol_1.PROTOCOL.ServiceFn('repository_remove_with_passport'),
|
|
246
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, service), txb.pure((0, util_1.array_unique)(repository_address), 'vector<address>'), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
247
|
+
typeArguments: [pay_type]
|
|
178
248
|
});
|
|
179
249
|
}
|
|
180
250
|
}
|
|
@@ -182,214 +252,350 @@ function service_repository_remove(pay_type, txb, service, permission, repositor
|
|
|
182
252
|
if (removeall) {
|
|
183
253
|
txb.moveCall({
|
|
184
254
|
target: protocol_1.PROTOCOL.ServiceFn('repository_remove_all'),
|
|
185
|
-
arguments: [service, permission],
|
|
255
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
186
256
|
typeArguments: [pay_type]
|
|
187
257
|
});
|
|
188
258
|
}
|
|
189
259
|
else {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
typeArguments: [pay_type]
|
|
195
|
-
});
|
|
260
|
+
txb.moveCall({
|
|
261
|
+
target: protocol_1.PROTOCOL.ServiceFn('repository_remove'),
|
|
262
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), txb.pure((0, util_1.array_unique)(repository_address), 'vector<address>'), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
263
|
+
typeArguments: [pay_type]
|
|
196
264
|
});
|
|
197
265
|
}
|
|
198
266
|
}
|
|
267
|
+
return true;
|
|
199
268
|
}
|
|
200
269
|
exports.service_repository_remove = service_repository_remove;
|
|
201
270
|
function service_add_withdraw_guards(pay_type, txb, service, permission, guards, passport) {
|
|
271
|
+
if (!(0, protocol_1.IsValidObjects)([service, permission]))
|
|
272
|
+
return false;
|
|
273
|
+
if (!(0, protocol_1.IsValidArgType)(pay_type))
|
|
274
|
+
return false;
|
|
275
|
+
let bValid = true;
|
|
276
|
+
guards.forEach((v) => {
|
|
277
|
+
if (!(0, protocol_1.IsValidObjects)([v.guard]))
|
|
278
|
+
return false;
|
|
279
|
+
if (!(0, protocol_1.IsValidPercent)(v.percent))
|
|
280
|
+
return false;
|
|
281
|
+
});
|
|
282
|
+
if (!bValid)
|
|
283
|
+
return false;
|
|
202
284
|
guards.forEach((guard) => {
|
|
203
|
-
let arg = guard.guard;
|
|
204
|
-
if (typeof arg == "string") {
|
|
205
|
-
arg = txb.object(guard.guard);
|
|
206
|
-
}
|
|
207
285
|
if (passport) {
|
|
208
286
|
txb.moveCall({
|
|
209
287
|
target: protocol_1.PROTOCOL.ServiceFn('withdraw_guard_add_with_passport'),
|
|
210
|
-
arguments: [passport, service,
|
|
288
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, guard.guard), txb.pure(guard.percent, bcs_1.BCS.U8), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
211
289
|
typeArguments: [pay_type]
|
|
212
290
|
});
|
|
213
291
|
}
|
|
214
292
|
else {
|
|
215
293
|
txb.moveCall({
|
|
216
294
|
target: protocol_1.PROTOCOL.ServiceFn('withdraw_guard_add'),
|
|
217
|
-
arguments: [service,
|
|
295
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, guard.guard), txb.pure(guard.percent, bcs_1.BCS.U8), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
218
296
|
typeArguments: [pay_type]
|
|
219
297
|
});
|
|
220
298
|
}
|
|
221
299
|
});
|
|
300
|
+
return true;
|
|
222
301
|
}
|
|
223
302
|
exports.service_add_withdraw_guards = service_add_withdraw_guards;
|
|
224
|
-
function service_remove_withdraw_guards(pay_type, txb, service, permission, guard_address, passport) {
|
|
225
|
-
|
|
226
|
-
|
|
303
|
+
function service_remove_withdraw_guards(pay_type, txb, service, permission, guard_address, removeall, passport) {
|
|
304
|
+
if (!(0, protocol_1.IsValidObjects)([service, permission]))
|
|
305
|
+
return false;
|
|
306
|
+
if (!(0, protocol_1.IsValidArgType)(pay_type))
|
|
307
|
+
return false;
|
|
308
|
+
if (!removeall && !guard_address)
|
|
309
|
+
return false;
|
|
310
|
+
if (guard_address && !(0, protocol_1.IsValidArray)(guard_address, protocol_1.IsValidAddress))
|
|
311
|
+
return false;
|
|
312
|
+
if (passport) {
|
|
313
|
+
if (removeall) {
|
|
314
|
+
txb.moveCall({
|
|
315
|
+
target: protocol_1.PROTOCOL.ServiceFn('withdraw_guard_remove_all_with_passport'),
|
|
316
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
317
|
+
typeArguments: [pay_type]
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
227
321
|
txb.moveCall({
|
|
228
322
|
target: protocol_1.PROTOCOL.ServiceFn('withdraw_guard_remove_with_passport'),
|
|
229
|
-
arguments: [passport, service, txb.pure(
|
|
323
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, service), txb.pure((0, util_1.array_unique)(guard_address), 'vector<address>'), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
324
|
+
typeArguments: [pay_type]
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
else {
|
|
329
|
+
if (removeall) {
|
|
330
|
+
txb.moveCall({
|
|
331
|
+
target: protocol_1.PROTOCOL.ServiceFn('withdraw_guard_remove_all'),
|
|
332
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
230
333
|
typeArguments: [pay_type]
|
|
231
334
|
});
|
|
232
335
|
}
|
|
233
336
|
else {
|
|
234
337
|
txb.moveCall({
|
|
235
338
|
target: protocol_1.PROTOCOL.ServiceFn('withdraw_guard_remove'),
|
|
236
|
-
arguments: [service, txb.pure(
|
|
339
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), txb.pure((0, util_1.array_unique)(guard_address), 'vector<address>'), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
237
340
|
typeArguments: [pay_type]
|
|
238
341
|
});
|
|
239
342
|
}
|
|
240
|
-
}
|
|
343
|
+
}
|
|
344
|
+
return true;
|
|
241
345
|
}
|
|
242
346
|
exports.service_remove_withdraw_guards = service_remove_withdraw_guards;
|
|
243
347
|
function service_add_refund_guards(pay_type, txb, service, permission, guards, passport) {
|
|
348
|
+
if (!(0, protocol_1.IsValidObjects)([service, permission]))
|
|
349
|
+
return false;
|
|
350
|
+
if (!(0, protocol_1.IsValidArgType)(pay_type))
|
|
351
|
+
return false;
|
|
352
|
+
let bValid = true;
|
|
353
|
+
guards.forEach((v) => {
|
|
354
|
+
if (!(0, protocol_1.IsValidObjects)([v.guard]))
|
|
355
|
+
return false;
|
|
356
|
+
if (!(0, protocol_1.IsValidPercent)(v.percent))
|
|
357
|
+
return false;
|
|
358
|
+
});
|
|
359
|
+
if (!bValid)
|
|
360
|
+
return false;
|
|
244
361
|
guards.forEach((guard) => {
|
|
245
|
-
let arg = guard.guard;
|
|
246
|
-
if (typeof arg == "string") {
|
|
247
|
-
arg = txb.object(guard.guard);
|
|
248
|
-
}
|
|
249
362
|
if (passport) {
|
|
250
363
|
txb.moveCall({
|
|
251
364
|
target: protocol_1.PROTOCOL.ServiceFn('refund_guard_add_with_passport'),
|
|
252
|
-
arguments: [passport, service,
|
|
365
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, guard.guard), txb.pure(guard.percent, bcs_1.BCS.U8), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
253
366
|
typeArguments: [pay_type]
|
|
254
367
|
});
|
|
255
368
|
}
|
|
256
369
|
else {
|
|
257
370
|
txb.moveCall({
|
|
258
371
|
target: protocol_1.PROTOCOL.ServiceFn('refund_guard_add'),
|
|
259
|
-
arguments: [service,
|
|
372
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, guard.guard), txb.pure(guard.percent, bcs_1.BCS.U8), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
260
373
|
typeArguments: [pay_type]
|
|
261
374
|
});
|
|
262
375
|
}
|
|
263
376
|
});
|
|
377
|
+
return true;
|
|
264
378
|
}
|
|
265
379
|
exports.service_add_refund_guards = service_add_refund_guards;
|
|
266
|
-
function service_remove_refund_guards(pay_type, txb, service, permission, guard_address) {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
380
|
+
function service_remove_refund_guards(pay_type, txb, service, permission, guard_address, removeall, passport) {
|
|
381
|
+
if (!(0, protocol_1.IsValidObjects)([service, permission]))
|
|
382
|
+
return false;
|
|
383
|
+
if (!(0, protocol_1.IsValidArgType)(pay_type))
|
|
384
|
+
return false;
|
|
385
|
+
if (!guard_address && !removeall)
|
|
386
|
+
return false;
|
|
387
|
+
if (guard_address && !(0, protocol_1.IsValidArray)(guard_address, protocol_1.IsValidAddress))
|
|
388
|
+
return false;
|
|
389
|
+
if (passport) {
|
|
390
|
+
if (removeall) {
|
|
391
|
+
txb.moveCall({
|
|
392
|
+
target: protocol_1.PROTOCOL.ServiceFn('refund_guard_remove_all_with_passport'),
|
|
393
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
394
|
+
typeArguments: [pay_type]
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
else {
|
|
398
|
+
txb.moveCall({
|
|
399
|
+
target: protocol_1.PROTOCOL.ServiceFn('refund_guard_remove_with_passport'),
|
|
400
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, service), txb.pure((0, util_1.array_unique)(guard_address), 'vector<address>'), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
401
|
+
typeArguments: [pay_type]
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
else {
|
|
406
|
+
if (removeall) {
|
|
407
|
+
txb.moveCall({
|
|
408
|
+
target: protocol_1.PROTOCOL.ServiceFn('refund_guard_remove_all'),
|
|
409
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
410
|
+
typeArguments: [pay_type]
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
else {
|
|
414
|
+
txb.moveCall({
|
|
415
|
+
target: protocol_1.PROTOCOL.ServiceFn('refund_guard_remove'),
|
|
416
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), txb.pure((0, util_1.array_unique)(guard_address), 'vector<address>'), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
417
|
+
typeArguments: [pay_type]
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
return true;
|
|
274
422
|
}
|
|
275
423
|
exports.service_remove_refund_guards = service_remove_refund_guards;
|
|
276
424
|
function service_add_sale(pay_type, txb, service, permission, sales, passport) {
|
|
425
|
+
if (!(0, protocol_1.IsValidObjects)([service, permission]))
|
|
426
|
+
return false;
|
|
427
|
+
if (!(0, protocol_1.IsValidArgType)(pay_type))
|
|
428
|
+
return false;
|
|
429
|
+
let bValid = true;
|
|
430
|
+
sales.forEach((v) => {
|
|
431
|
+
if (!(0, protocol_1.IsValidName)(v.item))
|
|
432
|
+
bValid = false;
|
|
433
|
+
if (!(0, protocol_1.IsValidInt)(v.price))
|
|
434
|
+
bValid = false;
|
|
435
|
+
if (!(0, protocol_1.IsValidInt)(v.stock))
|
|
436
|
+
bValid = false;
|
|
437
|
+
});
|
|
438
|
+
if (!bValid)
|
|
439
|
+
return false;
|
|
277
440
|
if (passport) {
|
|
278
441
|
sales.forEach((sale) => txb.moveCall({
|
|
279
442
|
target: protocol_1.PROTOCOL.ServiceFn('sales_add_with_passport'),
|
|
280
|
-
arguments: [passport,
|
|
443
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, service), txb.pure(sale.item), txb.pure(sale.price, bcs_1.BCS.U64), txb.pure(sale.stock, bcs_1.BCS.U64), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
281
444
|
typeArguments: [pay_type]
|
|
282
445
|
}));
|
|
283
446
|
}
|
|
284
447
|
else {
|
|
285
448
|
sales.forEach((sale) => txb.moveCall({
|
|
286
449
|
target: protocol_1.PROTOCOL.ServiceFn('sales_add'),
|
|
287
|
-
arguments: [
|
|
450
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), txb.pure(sale.item), txb.pure(sale.price, bcs_1.BCS.U64), txb.pure(sale.stock, bcs_1.BCS.U64), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
288
451
|
typeArguments: [pay_type]
|
|
289
452
|
}));
|
|
290
453
|
}
|
|
454
|
+
return true;
|
|
291
455
|
}
|
|
292
456
|
exports.service_add_sale = service_add_sale;
|
|
293
|
-
function
|
|
457
|
+
function service_remove_sales(pay_type, txb, service, permission, sales, removeall, passport) {
|
|
458
|
+
if (!(0, protocol_1.IsValidObjects)([service, permission]))
|
|
459
|
+
return false;
|
|
460
|
+
if (!(0, protocol_1.IsValidArgType)(pay_type))
|
|
461
|
+
return false;
|
|
462
|
+
if (!removeall && !sales)
|
|
463
|
+
return false;
|
|
464
|
+
if (sales && !(0, protocol_1.IsValidArray)(sales, protocol_1.IsValidName))
|
|
465
|
+
return false;
|
|
294
466
|
if (passport) {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
467
|
+
if (removeall) {
|
|
468
|
+
txb.moveCall({
|
|
469
|
+
target: protocol_1.PROTOCOL.ServiceFn('sales_remove_all_with_passport'),
|
|
470
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
471
|
+
typeArguments: [pay_type]
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
else {
|
|
475
|
+
txb.moveCall({
|
|
476
|
+
target: protocol_1.PROTOCOL.ServiceFn('sales_remove_with_passport'),
|
|
477
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, service), txb.pure(util_1.BCS_CONVERT.ser_vector_string((0, util_1.array_unique)(sales))), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
478
|
+
typeArguments: [pay_type]
|
|
479
|
+
});
|
|
480
|
+
}
|
|
300
481
|
}
|
|
301
482
|
else {
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
483
|
+
if (removeall) {
|
|
484
|
+
txb.moveCall({
|
|
485
|
+
target: protocol_1.PROTOCOL.ServiceFn('sales_remove_all'),
|
|
486
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
487
|
+
typeArguments: [pay_type]
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
else {
|
|
491
|
+
txb.moveCall({
|
|
492
|
+
target: protocol_1.PROTOCOL.ServiceFn('sales_remove'),
|
|
493
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), txb.pure(util_1.BCS_CONVERT.ser_vector_string((0, util_1.array_unique)(sales))), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
494
|
+
typeArguments: [pay_type]
|
|
495
|
+
});
|
|
496
|
+
}
|
|
307
497
|
}
|
|
498
|
+
return true;
|
|
308
499
|
}
|
|
309
|
-
exports.
|
|
500
|
+
exports.service_remove_sales = service_remove_sales;
|
|
310
501
|
var Service_Discount_Type;
|
|
311
502
|
(function (Service_Discount_Type) {
|
|
312
503
|
Service_Discount_Type[Service_Discount_Type["ratio"] = 0] = "ratio";
|
|
313
504
|
Service_Discount_Type[Service_Discount_Type["minus"] = 1] = "minus";
|
|
314
505
|
})(Service_Discount_Type || (exports.Service_Discount_Type = Service_Discount_Type = {}));
|
|
315
|
-
const
|
|
316
|
-
const MAX_DISCOUNT_RECEIVER_COUNT =
|
|
317
|
-
exports.MAX_DISCOUNT_COUNT_ONCE = 100;
|
|
506
|
+
const MAX_DISCOUNT_COUNT_ONCE = 200;
|
|
507
|
+
const MAX_DISCOUNT_RECEIVER_COUNT = 200;
|
|
318
508
|
function service_discount_transfer(pay_type, txb, service, permission, discount_dispatch, passport) {
|
|
319
|
-
if (
|
|
320
|
-
return
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
509
|
+
if (!(0, protocol_1.IsValidObjects)([service, permission]))
|
|
510
|
+
return false;
|
|
511
|
+
if (!(0, protocol_1.IsValidArgType)(pay_type))
|
|
512
|
+
return false;
|
|
513
|
+
if (!discount_dispatch || discount_dispatch.length > MAX_DISCOUNT_RECEIVER_COUNT)
|
|
514
|
+
return false;
|
|
515
|
+
let bValid = true;
|
|
516
|
+
discount_dispatch.forEach((v) => {
|
|
517
|
+
if (!(0, protocol_1.IsValidAddress)(v.receiver))
|
|
518
|
+
bValid = false;
|
|
519
|
+
if (!(0, protocol_1.IsValidUint)(v.count) || v.count > MAX_DISCOUNT_COUNT_ONCE)
|
|
520
|
+
return false;
|
|
521
|
+
if (!(0, protocol_1.IsValidName_AllowEmpty)(v.discount.name))
|
|
522
|
+
return false;
|
|
523
|
+
if (v.discount.type == Service_Discount_Type.ratio && !(0, protocol_1.IsValidPercent)(v.discount.off))
|
|
524
|
+
return false;
|
|
525
|
+
if (!(0, protocol_1.IsValidUint)(v.discount.duration_minutes))
|
|
526
|
+
return false;
|
|
527
|
+
if (v.discount?.time_start && !(0, protocol_1.IsValidUint)(v.discount.time_start))
|
|
528
|
+
return false;
|
|
529
|
+
if (v.discount?.price_greater && !(0, protocol_1.IsValidInt)(v.discount.price_greater))
|
|
530
|
+
return false;
|
|
531
|
+
});
|
|
532
|
+
if (!bValid)
|
|
533
|
+
return false;
|
|
330
534
|
discount_dispatch.forEach((discount) => {
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
let price_greater = txb.pure([], bcs_1.BCS.U8);
|
|
336
|
-
if (discount.discount?.price_greater) {
|
|
337
|
-
price_greater = txb.pure(util_1.BCS_CONVERT.ser_option_u64(discount.discount.price_greater));
|
|
338
|
-
}
|
|
339
|
-
let time_start = txb.pure([], bcs_1.BCS.U8);
|
|
340
|
-
if (discount.discount.time_start) {
|
|
341
|
-
time_start = txb.pure(util_1.BCS_CONVERT.ser_option_u64(discount.discount.time_start));
|
|
342
|
-
}
|
|
535
|
+
let price_greater = discount.discount?.price_greater ?
|
|
536
|
+
txb.pure(util_1.BCS_CONVERT.ser_option_u64(discount.discount.price_greater)) : (0, protocol_1.OptionNone)(txb);
|
|
537
|
+
let time_start = discount.discount?.time_start ?
|
|
538
|
+
txb.pure(util_1.BCS_CONVERT.ser_option_u64(discount.discount.time_start)) : (0, protocol_1.OptionNone)(txb);
|
|
343
539
|
if (passport) {
|
|
344
540
|
txb.moveCall({
|
|
345
541
|
target: protocol_1.PROTOCOL.ServiceFn('dicscount_create_with_passport'),
|
|
346
|
-
arguments: [passport,
|
|
347
|
-
time_start, txb.pure(discount.discount.duration_minutes, bcs_1.BCS.U64), txb.pure(discount.count, bcs_1.BCS.U64), permission, txb.pure(discount.receiver, bcs_1.BCS.ADDRESS), txb.object(protocol_1.CLOCK_OBJECT)],
|
|
542
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, service), txb.pure(discount.discount.name), txb.pure(discount.discount.type, bcs_1.BCS.U8), txb.pure(discount.discount.off, bcs_1.BCS.U64), price_greater,
|
|
543
|
+
time_start, txb.pure(discount.discount.duration_minutes, bcs_1.BCS.U64), txb.pure(discount.count, bcs_1.BCS.U64), (0, protocol_1.TXB_OBJECT)(txb, permission), txb.pure(discount.receiver, bcs_1.BCS.ADDRESS), txb.object(protocol_1.CLOCK_OBJECT)],
|
|
348
544
|
typeArguments: [pay_type]
|
|
349
545
|
});
|
|
350
546
|
}
|
|
351
547
|
else {
|
|
352
548
|
txb.moveCall({
|
|
353
549
|
target: protocol_1.PROTOCOL.ServiceFn('dicscount_create'),
|
|
354
|
-
arguments: [
|
|
355
|
-
time_start, txb.pure(discount.discount.duration_minutes, bcs_1.BCS.U64), txb.pure(discount.count, bcs_1.BCS.U64), permission, txb.pure(discount.receiver, bcs_1.BCS.ADDRESS), txb.object(protocol_1.CLOCK_OBJECT)],
|
|
550
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), txb.pure(discount.discount.name), txb.pure(discount.discount.type, bcs_1.BCS.U8), txb.pure(discount.discount.off, bcs_1.BCS.U64), price_greater,
|
|
551
|
+
time_start, txb.pure(discount.discount.duration_minutes, bcs_1.BCS.U64), txb.pure(discount.count, bcs_1.BCS.U64), (0, protocol_1.TXB_OBJECT)(txb, permission), txb.pure(discount.receiver, bcs_1.BCS.ADDRESS), txb.object(protocol_1.CLOCK_OBJECT)],
|
|
356
552
|
typeArguments: [pay_type]
|
|
357
553
|
});
|
|
358
554
|
}
|
|
359
555
|
});
|
|
556
|
+
return true;
|
|
360
557
|
}
|
|
361
558
|
exports.service_discount_transfer = service_discount_transfer;
|
|
362
559
|
// 同时支持withdraw guard和permission guard
|
|
363
560
|
function service_withdraw(pay_type, txb, service, permission, order, passport) {
|
|
561
|
+
if (!(0, protocol_1.IsValidObjects)([service, permission, order]))
|
|
562
|
+
return false;
|
|
563
|
+
if (!(0, protocol_1.IsValidArgType)(pay_type))
|
|
564
|
+
return false;
|
|
364
565
|
if (passport) {
|
|
365
566
|
txb.moveCall({
|
|
366
567
|
target: protocol_1.PROTOCOL.ServiceFn('withdraw_with_passport'),
|
|
367
|
-
arguments: [passport, service, order, passport, permission],
|
|
568
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, order), passport, (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
368
569
|
typeArguments: [pay_type]
|
|
369
570
|
});
|
|
370
571
|
}
|
|
371
572
|
else {
|
|
372
573
|
txb.moveCall({
|
|
373
574
|
target: protocol_1.PROTOCOL.ServiceFn('withdraw'),
|
|
374
|
-
arguments: [service, order, permission],
|
|
575
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, order), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
375
576
|
typeArguments: [pay_type]
|
|
376
577
|
});
|
|
377
578
|
}
|
|
579
|
+
return true;
|
|
378
580
|
}
|
|
379
581
|
exports.service_withdraw = service_withdraw;
|
|
380
582
|
function service_set_buy_guard(pay_type, txb, service, permission, guard, passport) {
|
|
583
|
+
if (!(0, protocol_1.IsValidObjects)([service, permission]))
|
|
584
|
+
return false;
|
|
585
|
+
if (!(0, protocol_1.IsValidArgType)(pay_type))
|
|
586
|
+
return false;
|
|
381
587
|
if (passport) {
|
|
382
588
|
if (guard) {
|
|
383
589
|
txb.moveCall({
|
|
384
590
|
target: protocol_1.PROTOCOL.ServiceFn('buy_guard_set_with_passport'),
|
|
385
|
-
arguments: [passport, service, guard, permission],
|
|
591
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, guard), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
386
592
|
typeArguments: [pay_type]
|
|
387
593
|
});
|
|
388
594
|
}
|
|
389
595
|
else {
|
|
390
596
|
txb.moveCall({
|
|
391
597
|
target: protocol_1.PROTOCOL.ServiceFn('buy_guard_none_with_passport'),
|
|
392
|
-
arguments: [passport, service, permission],
|
|
598
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
393
599
|
typeArguments: [pay_type]
|
|
394
600
|
});
|
|
395
601
|
}
|
|
@@ -398,33 +604,38 @@ function service_set_buy_guard(pay_type, txb, service, permission, guard, passpo
|
|
|
398
604
|
if (guard) {
|
|
399
605
|
txb.moveCall({
|
|
400
606
|
target: protocol_1.PROTOCOL.ServiceFn('buy_guard_set'),
|
|
401
|
-
arguments: [service, guard, permission],
|
|
607
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, guard), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
402
608
|
typeArguments: [pay_type]
|
|
403
609
|
});
|
|
404
610
|
}
|
|
405
611
|
else {
|
|
406
612
|
txb.moveCall({
|
|
407
613
|
target: protocol_1.PROTOCOL.ServiceFn('buy_guard_none'),
|
|
408
|
-
arguments: [service, permission],
|
|
614
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
409
615
|
typeArguments: [pay_type]
|
|
410
616
|
});
|
|
411
617
|
}
|
|
412
618
|
}
|
|
619
|
+
return true;
|
|
413
620
|
}
|
|
414
621
|
exports.service_set_buy_guard = service_set_buy_guard;
|
|
415
622
|
function service_set_machine(pay_type, txb, service, permission, machine, passport) {
|
|
623
|
+
if (!(0, protocol_1.IsValidObjects)([service, permission]))
|
|
624
|
+
return false;
|
|
625
|
+
if (!(0, protocol_1.IsValidArgType)(pay_type))
|
|
626
|
+
return false;
|
|
416
627
|
if (passport) {
|
|
417
628
|
if (machine) {
|
|
418
629
|
txb.moveCall({
|
|
419
630
|
target: protocol_1.PROTOCOL.ServiceFn('machine_set_with_passport'),
|
|
420
|
-
arguments: [passport, service, machine, permission],
|
|
631
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, machine), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
421
632
|
typeArguments: [pay_type]
|
|
422
633
|
});
|
|
423
634
|
}
|
|
424
635
|
else {
|
|
425
636
|
txb.moveCall({
|
|
426
637
|
target: protocol_1.PROTOCOL.ServiceFn('machine_none_with_passport'),
|
|
427
|
-
arguments: [passport, service, permission],
|
|
638
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
428
639
|
typeArguments: [pay_type]
|
|
429
640
|
});
|
|
430
641
|
}
|
|
@@ -433,195 +644,269 @@ function service_set_machine(pay_type, txb, service, permission, machine, passpo
|
|
|
433
644
|
if (machine) {
|
|
434
645
|
txb.moveCall({
|
|
435
646
|
target: protocol_1.PROTOCOL.ServiceFn('machine_set'),
|
|
436
|
-
arguments: [service, machine, permission],
|
|
647
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, machine), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
437
648
|
typeArguments: [pay_type]
|
|
438
649
|
});
|
|
439
650
|
}
|
|
440
651
|
else {
|
|
441
652
|
txb.moveCall({
|
|
442
653
|
target: protocol_1.PROTOCOL.ServiceFn('machine_none'),
|
|
443
|
-
arguments: [service, permission],
|
|
654
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
444
655
|
typeArguments: [pay_type]
|
|
445
656
|
});
|
|
446
657
|
}
|
|
447
658
|
}
|
|
659
|
+
return true;
|
|
448
660
|
}
|
|
449
661
|
exports.service_set_machine = service_set_machine;
|
|
450
|
-
function service_set_endpoint(pay_type, txb, service, permission,
|
|
451
|
-
if (
|
|
452
|
-
return
|
|
453
|
-
|
|
662
|
+
function service_set_endpoint(pay_type, txb, service, permission, endpoint, passport) {
|
|
663
|
+
if (!(0, protocol_1.IsValidObjects)([service, permission]))
|
|
664
|
+
return false;
|
|
665
|
+
if (!(0, protocol_1.IsValidArgType)(pay_type))
|
|
666
|
+
return false;
|
|
667
|
+
if (endpoint && !(0, protocol_1.IsValidEndpoint)(endpoint))
|
|
668
|
+
return false;
|
|
669
|
+
let ep = endpoint ? txb.pure(util_1.BCS_CONVERT.ser_option_string(endpoint)) : (0, protocol_1.OptionNone)(txb);
|
|
454
670
|
if (passport) {
|
|
455
671
|
txb.moveCall({
|
|
456
672
|
target: protocol_1.PROTOCOL.ServiceFn('endpoint_set_with_passport'),
|
|
457
|
-
arguments: [passport, service,
|
|
673
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, service), ep, (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
458
674
|
typeArguments: [pay_type]
|
|
459
675
|
});
|
|
460
676
|
}
|
|
461
677
|
else {
|
|
462
678
|
txb.moveCall({
|
|
463
679
|
target: protocol_1.PROTOCOL.ServiceFn('endpoint_set'),
|
|
464
|
-
arguments: [service,
|
|
680
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), ep, (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
465
681
|
typeArguments: [pay_type]
|
|
466
682
|
});
|
|
467
683
|
}
|
|
684
|
+
return true;
|
|
468
685
|
}
|
|
469
686
|
exports.service_set_endpoint = service_set_endpoint;
|
|
470
687
|
function service_publish(pay_type, txb, service, permission, passport) {
|
|
688
|
+
if (!(0, protocol_1.IsValidObjects)([service, permission]))
|
|
689
|
+
return false;
|
|
690
|
+
if (!(0, protocol_1.IsValidArgType)(pay_type))
|
|
691
|
+
return false;
|
|
471
692
|
if (passport) {
|
|
472
693
|
txb.moveCall({
|
|
473
694
|
target: protocol_1.PROTOCOL.ServiceFn('publish_with_passport'),
|
|
474
|
-
arguments: [passport, service, permission],
|
|
695
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
475
696
|
typeArguments: [pay_type]
|
|
476
697
|
});
|
|
477
698
|
}
|
|
478
699
|
else {
|
|
479
700
|
txb.moveCall({
|
|
480
701
|
target: protocol_1.PROTOCOL.ServiceFn('publish'),
|
|
481
|
-
arguments: [service, permission],
|
|
702
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
482
703
|
typeArguments: [pay_type]
|
|
483
704
|
});
|
|
484
705
|
}
|
|
706
|
+
return true;
|
|
485
707
|
}
|
|
486
708
|
exports.service_publish = service_publish;
|
|
487
709
|
function service_clone(pay_type, txb, service, permission, passport) {
|
|
710
|
+
if (!(0, protocol_1.IsValidObjects)([service, permission]))
|
|
711
|
+
return false;
|
|
712
|
+
if (!(0, protocol_1.IsValidArgType)(pay_type))
|
|
713
|
+
return false;
|
|
488
714
|
if (passport) {
|
|
489
715
|
return txb.moveCall({
|
|
490
716
|
target: protocol_1.PROTOCOL.ServiceFn('clone_withpassport'),
|
|
491
|
-
arguments: [passport, service, permission],
|
|
717
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
492
718
|
typeArguments: [pay_type]
|
|
493
719
|
});
|
|
494
720
|
}
|
|
495
721
|
else {
|
|
496
722
|
return txb.moveCall({
|
|
497
723
|
target: protocol_1.PROTOCOL.ServiceFn('clone'),
|
|
498
|
-
arguments: [service, permission],
|
|
724
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
499
725
|
typeArguments: [pay_type]
|
|
500
726
|
});
|
|
501
727
|
}
|
|
728
|
+
return true;
|
|
502
729
|
}
|
|
503
730
|
exports.service_clone = service_clone;
|
|
731
|
+
var BuyRequiredEnum;
|
|
732
|
+
(function (BuyRequiredEnum) {
|
|
733
|
+
BuyRequiredEnum["address"] = "address";
|
|
734
|
+
BuyRequiredEnum["phone"] = "phone";
|
|
735
|
+
BuyRequiredEnum["name"] = "name";
|
|
736
|
+
BuyRequiredEnum["postcode"] = "postcode";
|
|
737
|
+
})(BuyRequiredEnum || (exports.BuyRequiredEnum = BuyRequiredEnum = {}));
|
|
504
738
|
function service_set_customer_required(pay_type, txb, service, permission, service_pubkey, customer_required, passport) {
|
|
505
|
-
if (
|
|
506
|
-
return
|
|
739
|
+
if (!(0, protocol_1.IsValidObjects)([service, permission]))
|
|
740
|
+
return false;
|
|
741
|
+
if (!(0, protocol_1.IsValidArgType)(pay_type))
|
|
742
|
+
return false;
|
|
743
|
+
if (!service_pubkey || !customer_required)
|
|
744
|
+
return false;
|
|
507
745
|
if (passport) {
|
|
508
746
|
txb.moveCall({
|
|
509
747
|
target: protocol_1.PROTOCOL.ServiceFn('required_set_with_passport'),
|
|
510
|
-
arguments: [passport, service, txb.pure(
|
|
748
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, service), txb.pure(util_1.BCS_CONVERT.ser_vector_vector_u8((0, util_1.array_unique)(customer_required))), txb.pure(service_pubkey, 'vector<u8>'), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
511
749
|
typeArguments: [pay_type]
|
|
512
750
|
});
|
|
513
751
|
}
|
|
514
752
|
else {
|
|
515
753
|
txb.moveCall({
|
|
516
754
|
target: protocol_1.PROTOCOL.ServiceFn('required_set'),
|
|
517
|
-
arguments: [service, txb.pure(
|
|
755
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), txb.pure(util_1.BCS_CONVERT.ser_vector_vector_u8((0, util_1.array_unique)(customer_required))), txb.pure(service_pubkey, 'vector<u8>'), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
518
756
|
typeArguments: [pay_type]
|
|
519
757
|
});
|
|
520
758
|
}
|
|
759
|
+
return true;
|
|
521
760
|
}
|
|
522
761
|
exports.service_set_customer_required = service_set_customer_required;
|
|
523
762
|
function service_remove_customer_required(pay_type, txb, service, permission, passport) {
|
|
763
|
+
if (!(0, protocol_1.IsValidObjects)([service, permission]))
|
|
764
|
+
return false;
|
|
765
|
+
if (!(0, protocol_1.IsValidArgType)(pay_type))
|
|
766
|
+
return false;
|
|
524
767
|
if (passport) {
|
|
525
768
|
txb.moveCall({
|
|
526
769
|
target: protocol_1.PROTOCOL.ServiceFn('required_none_with_passport'),
|
|
527
|
-
arguments: [passport, service, permission],
|
|
770
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
528
771
|
typeArguments: [pay_type]
|
|
529
772
|
});
|
|
530
773
|
}
|
|
531
774
|
else {
|
|
532
775
|
txb.moveCall({
|
|
533
776
|
target: protocol_1.PROTOCOL.ServiceFn('required_none'),
|
|
534
|
-
arguments: [service, permission],
|
|
777
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
535
778
|
typeArguments: [pay_type]
|
|
536
779
|
});
|
|
537
780
|
}
|
|
781
|
+
return true;
|
|
538
782
|
}
|
|
539
783
|
exports.service_remove_customer_required = service_remove_customer_required;
|
|
540
784
|
function service_change_required_pubkey(pay_type, txb, service, permission, service_pubkey, passport) {
|
|
785
|
+
if (!(0, protocol_1.IsValidObjects)([service, permission]))
|
|
786
|
+
return false;
|
|
787
|
+
if (!(0, protocol_1.IsValidArgType)(pay_type))
|
|
788
|
+
return false;
|
|
541
789
|
if (!service_pubkey)
|
|
542
|
-
return
|
|
790
|
+
return false;
|
|
543
791
|
if (passport) {
|
|
544
792
|
txb.moveCall({
|
|
545
793
|
target: protocol_1.PROTOCOL.ServiceFn('required_pubkey_set_with_passport'),
|
|
546
|
-
arguments: [passport, service, txb.pure(service_pubkey, 'vector<u8>'), permission],
|
|
794
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, service), txb.pure(service_pubkey, 'vector<u8>'), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
547
795
|
typeArguments: [pay_type]
|
|
548
796
|
});
|
|
549
797
|
}
|
|
550
798
|
else {
|
|
551
799
|
txb.moveCall({
|
|
552
800
|
target: protocol_1.PROTOCOL.ServiceFn('required_pubkey_set'),
|
|
553
|
-
arguments: [service, txb.pure(service_pubkey, 'vector<u8>'), permission],
|
|
801
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), txb.pure(service_pubkey, 'vector<u8>'), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
554
802
|
typeArguments: [pay_type]
|
|
555
803
|
});
|
|
556
804
|
}
|
|
805
|
+
return true;
|
|
557
806
|
}
|
|
558
807
|
exports.service_change_required_pubkey = service_change_required_pubkey;
|
|
559
808
|
function service_change_order_required_pubkey(pay_type, txb, service, permission, order, service_pubkey, passport) {
|
|
809
|
+
if (!(0, protocol_1.IsValidObjects)([service, permission, order]))
|
|
810
|
+
return false;
|
|
811
|
+
if (!(0, protocol_1.IsValidArgType)(pay_type))
|
|
812
|
+
return false;
|
|
560
813
|
if (!service_pubkey)
|
|
561
|
-
return
|
|
814
|
+
return false;
|
|
562
815
|
if (passport) {
|
|
563
816
|
txb.moveCall({
|
|
564
817
|
target: protocol_1.PROTOCOL.ServiceFn('order_pubkey_update_with_passport'),
|
|
565
|
-
arguments: [passport, service, order, txb.pure(service_pubkey, 'vector<u8>'), permission],
|
|
818
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, order), txb.pure(service_pubkey, 'vector<u8>'), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
566
819
|
typeArguments: [pay_type]
|
|
567
820
|
});
|
|
568
821
|
}
|
|
569
822
|
else {
|
|
570
823
|
txb.moveCall({
|
|
571
824
|
target: protocol_1.PROTOCOL.ServiceFn('order_pubkey_update'),
|
|
572
|
-
arguments: [service, order, txb.pure(service_pubkey, 'vector<u8>'), permission],
|
|
825
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, order), txb.pure(service_pubkey, 'vector<u8>'), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
573
826
|
typeArguments: [pay_type]
|
|
574
827
|
});
|
|
575
828
|
}
|
|
829
|
+
return true;
|
|
576
830
|
}
|
|
577
831
|
exports.service_change_order_required_pubkey = service_change_order_required_pubkey;
|
|
578
832
|
function service_pause(pay_type, txb, service, permission, pause, passport) {
|
|
833
|
+
if (!(0, protocol_1.IsValidObjects)([service, permission]))
|
|
834
|
+
return false;
|
|
835
|
+
if (!(0, protocol_1.IsValidArgType)(pay_type))
|
|
836
|
+
return false;
|
|
579
837
|
if (passport) {
|
|
580
838
|
txb.moveCall({
|
|
581
839
|
target: protocol_1.PROTOCOL.ServiceFn('pause_with_passport'),
|
|
582
|
-
arguments: [passport, service, txb.pure(pause, bcs_1.BCS.BOOL), permission],
|
|
840
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, service), txb.pure(pause, bcs_1.BCS.BOOL), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
583
841
|
typeArguments: [pay_type]
|
|
584
842
|
});
|
|
585
843
|
}
|
|
586
844
|
else {
|
|
587
845
|
txb.moveCall({
|
|
588
846
|
target: protocol_1.PROTOCOL.ServiceFn('pause'),
|
|
589
|
-
arguments: [service, txb.pure(pause, bcs_1.BCS.BOOL), permission],
|
|
847
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), txb.pure(pause, bcs_1.BCS.BOOL), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
590
848
|
typeArguments: [pay_type]
|
|
591
849
|
});
|
|
592
850
|
}
|
|
851
|
+
return true;
|
|
593
852
|
}
|
|
594
853
|
exports.service_pause = service_pause;
|
|
595
854
|
function customer_refund(pay_type, txb, service, order, passport) {
|
|
855
|
+
if (!(0, protocol_1.IsValidObjects)([service, order]))
|
|
856
|
+
return false;
|
|
857
|
+
if (!(0, protocol_1.IsValidArgType)(pay_type))
|
|
858
|
+
return false;
|
|
596
859
|
if (passport) {
|
|
597
860
|
txb.moveCall({
|
|
598
861
|
target: protocol_1.PROTOCOL.ServiceFn('refund_with_passport'),
|
|
599
|
-
arguments: [service, order, passport],
|
|
862
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, order), passport],
|
|
600
863
|
typeArguments: [pay_type]
|
|
601
864
|
});
|
|
602
865
|
}
|
|
603
866
|
else {
|
|
604
867
|
txb.moveCall({
|
|
605
868
|
target: protocol_1.PROTOCOL.ServiceFn('refund'),
|
|
606
|
-
arguments: [service, order],
|
|
869
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, order)],
|
|
607
870
|
typeArguments: [pay_type]
|
|
608
871
|
});
|
|
609
872
|
}
|
|
873
|
+
return true;
|
|
610
874
|
}
|
|
611
875
|
exports.customer_refund = customer_refund;
|
|
612
876
|
function update_order_required_info(pay_type, txb, service, order, customer_info_crypto) {
|
|
877
|
+
if (!(0, protocol_1.IsValidObjects)([service, order]))
|
|
878
|
+
return false;
|
|
879
|
+
if (!(0, protocol_1.IsValidArgType)(pay_type))
|
|
880
|
+
return false;
|
|
881
|
+
if (!customer_info_crypto.service_pubkey || !customer_info_crypto.customer_info_crypt)
|
|
882
|
+
return false;
|
|
613
883
|
txb.moveCall({
|
|
614
884
|
target: protocol_1.PROTOCOL.ServiceFn('order_required_info_update'),
|
|
615
|
-
arguments: [service,
|
|
885
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, order),
|
|
886
|
+
txb.pure(customer_info_crypto.service_pubkey, 'vector<u8>'),
|
|
616
887
|
txb.pure(customer_info_crypto.customer_pubkey, 'vector<u8>'),
|
|
617
|
-
txb.pure(
|
|
888
|
+
txb.pure(util_1.BCS_CONVERT.ser_vector_vector_u8((0, util_1.array_unique)(customer_info_crypto.customer_info_crypt)))],
|
|
618
889
|
typeArguments: [pay_type]
|
|
619
890
|
});
|
|
891
|
+
return true;
|
|
620
892
|
}
|
|
621
893
|
exports.update_order_required_info = update_order_required_info;
|
|
622
894
|
function buy(pay_type, txb, service, buy_items, coin, discount, service_machine, customer_info_crypto, passport) {
|
|
623
|
-
if (
|
|
624
|
-
return
|
|
895
|
+
if (!(0, protocol_1.IsValidObjects)([service]))
|
|
896
|
+
return false;
|
|
897
|
+
if (!(0, protocol_1.IsValidArgType)(pay_type))
|
|
898
|
+
return false;
|
|
899
|
+
if (!buy_items)
|
|
900
|
+
return false;
|
|
901
|
+
let bValid = true;
|
|
902
|
+
buy_items.forEach((v) => {
|
|
903
|
+
if (!(0, protocol_1.IsValidName)(v.item))
|
|
904
|
+
bValid = false;
|
|
905
|
+
if (!(0, protocol_1.IsValidUint)(v.count))
|
|
906
|
+
bValid = false;
|
|
907
|
+
});
|
|
908
|
+
if (!bValid)
|
|
909
|
+
return false;
|
|
625
910
|
let i = [];
|
|
626
911
|
let c = [];
|
|
627
912
|
let order;
|
|
@@ -630,15 +915,16 @@ function buy(pay_type, txb, service, buy_items, coin, discount, service_machine,
|
|
|
630
915
|
if (discount) {
|
|
631
916
|
order = txb.moveCall({
|
|
632
917
|
target: protocol_1.PROTOCOL.ServiceFn('dicount_buy_with_passport'),
|
|
633
|
-
arguments: [passport, service, txb.pure(util_1.BCS_CONVERT.ser_vector_string(i)),
|
|
634
|
-
txb.pure(util_1.BCS_CONVERT.ser_vector_u64(c)), coin, discount, txb.object(protocol_1.CLOCK_OBJECT)],
|
|
918
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, service), txb.pure(util_1.BCS_CONVERT.ser_vector_string(i)),
|
|
919
|
+
txb.pure(util_1.BCS_CONVERT.ser_vector_u64(c)), (0, protocol_1.TXB_OBJECT)(txb, coin), (0, protocol_1.TXB_OBJECT)(txb, discount), txb.object(protocol_1.CLOCK_OBJECT)],
|
|
920
|
+
typeArguments: [pay_type]
|
|
635
921
|
});
|
|
636
922
|
}
|
|
637
923
|
else {
|
|
638
924
|
order = txb.moveCall({
|
|
639
925
|
target: protocol_1.PROTOCOL.ServiceFn('buy_with_passport'),
|
|
640
|
-
arguments: [passport, service, txb.pure(util_1.BCS_CONVERT.ser_vector_string(i)),
|
|
641
|
-
txb.pure(util_1.BCS_CONVERT.ser_vector_u64(c)), coin],
|
|
926
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, service), txb.pure(util_1.BCS_CONVERT.ser_vector_string(i)),
|
|
927
|
+
txb.pure(util_1.BCS_CONVERT.ser_vector_u64(c)), (0, protocol_1.TXB_OBJECT)(txb, coin)],
|
|
642
928
|
typeArguments: [pay_type]
|
|
643
929
|
});
|
|
644
930
|
}
|
|
@@ -647,16 +933,16 @@ function buy(pay_type, txb, service, buy_items, coin, discount, service_machine,
|
|
|
647
933
|
if (discount) {
|
|
648
934
|
order = txb.moveCall({
|
|
649
935
|
target: protocol_1.PROTOCOL.ServiceFn('disoucnt_buy'),
|
|
650
|
-
arguments: [service, txb.pure(util_1.BCS_CONVERT.ser_vector_string(i)),
|
|
651
|
-
txb.pure(util_1.BCS_CONVERT.ser_vector_u64(c)), coin, discount, txb.object(protocol_1.CLOCK_OBJECT)],
|
|
936
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), txb.pure(util_1.BCS_CONVERT.ser_vector_string(i)),
|
|
937
|
+
txb.pure(util_1.BCS_CONVERT.ser_vector_u64(c)), (0, protocol_1.TXB_OBJECT)(txb, coin), (0, protocol_1.TXB_OBJECT)(txb, discount), txb.object(protocol_1.CLOCK_OBJECT)],
|
|
652
938
|
typeArguments: [pay_type]
|
|
653
939
|
});
|
|
654
940
|
}
|
|
655
941
|
else {
|
|
656
942
|
order = txb.moveCall({
|
|
657
943
|
target: protocol_1.PROTOCOL.ServiceFn('buy'),
|
|
658
|
-
arguments: [service, txb.pure(util_1.BCS_CONVERT.ser_vector_string(i)),
|
|
659
|
-
txb.pure(util_1.BCS_CONVERT.ser_vector_u64(c)), coin],
|
|
944
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), txb.pure(util_1.BCS_CONVERT.ser_vector_string(i)),
|
|
945
|
+
txb.pure(util_1.BCS_CONVERT.ser_vector_u64(c)), (0, protocol_1.TXB_OBJECT)(txb, coin)],
|
|
660
946
|
typeArguments: [pay_type]
|
|
661
947
|
});
|
|
662
948
|
}
|
|
@@ -667,32 +953,42 @@ function buy(pay_type, txb, service, buy_items, coin, discount, service_machine,
|
|
|
667
953
|
if (service_machine) {
|
|
668
954
|
return txb.moveCall({
|
|
669
955
|
target: protocol_1.PROTOCOL.ServiceFn('order_create_with_machine'),
|
|
670
|
-
arguments: [service, order, service_machine],
|
|
956
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, order), (0, protocol_1.TXB_OBJECT)(txb, service_machine)],
|
|
671
957
|
typeArguments: [pay_type]
|
|
672
958
|
});
|
|
673
959
|
}
|
|
674
960
|
else {
|
|
675
961
|
return txb.moveCall({
|
|
676
962
|
target: protocol_1.PROTOCOL.ServiceFn('order_create'),
|
|
677
|
-
arguments: [service, order],
|
|
963
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, order)],
|
|
678
964
|
typeArguments: [pay_type]
|
|
679
965
|
});
|
|
680
966
|
}
|
|
681
967
|
}
|
|
682
968
|
exports.buy = buy;
|
|
683
969
|
function order_bind_service_machine(pay_type, txb, service, order, service_machine) {
|
|
970
|
+
if (!(0, protocol_1.IsValidObjects)([service, order, service_machine]))
|
|
971
|
+
return false;
|
|
972
|
+
if (!(0, protocol_1.IsValidArgType)(pay_type))
|
|
973
|
+
return false;
|
|
684
974
|
txb.moveCall({
|
|
685
975
|
target: protocol_1.PROTOCOL.ServiceFn('order_create_with_machine'),
|
|
686
|
-
arguments: [service, order, service_machine],
|
|
976
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, order), (0, protocol_1.TXB_OBJECT)(txb, service_machine)],
|
|
687
977
|
typeArguments: [pay_type]
|
|
688
978
|
});
|
|
979
|
+
return true;
|
|
689
980
|
}
|
|
690
981
|
exports.order_bind_service_machine = order_bind_service_machine;
|
|
691
982
|
function change_permission(pay_type, txb, service, old_permission, new_permission) {
|
|
983
|
+
if (!(0, protocol_1.IsValidObjects)([service, old_permission, new_permission]))
|
|
984
|
+
return false;
|
|
985
|
+
if (!(0, protocol_1.IsValidArgType)(pay_type))
|
|
986
|
+
return false;
|
|
692
987
|
txb.moveCall({
|
|
693
988
|
target: protocol_1.PROTOCOL.ServiceFn('permission_set'),
|
|
694
|
-
arguments: [service, old_permission, new_permission],
|
|
989
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, old_permission), (0, protocol_1.TXB_OBJECT)(txb, new_permission)],
|
|
695
990
|
typeArguments: [pay_type]
|
|
696
991
|
});
|
|
992
|
+
return true;
|
|
697
993
|
}
|
|
698
994
|
exports.change_permission = change_permission;
|