@jetthai/cuora 1.1.127 → 1.1.128-dev-2
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/CHANGELOG.md +426 -0
- package/package.json +1 -1
- package/src/api/activity.js +28 -0
- package/src/api/auth.js +6 -0
- package/src/api/common.js +2 -1
- package/src/api/game.js +5 -4
- package/src/api/mailbox.js +9 -5
- package/src/api/payment.js +103 -8
- package/src/api/user.js +2 -0
- package/src/machine/activity/activity.js +56 -16
- package/src/machine/activity/activity_cash.js +78 -14
- package/src/machine/activity/cash_rain_activity.js +153 -0
- package/src/machine/activity/diamond_shop_activity_cash.js +57 -92
- package/src/machine/activity/diamond_shop_activity_vn.js +54 -89
- package/src/machine/activity/fafafa_activity.js +8 -1
- package/src/machine/activity/friend_invite_friends_activity.js +3 -1
- package/src/machine/activity/index.js +6 -0
- package/src/machine/activity/instant_rebate_activity.js +214 -0
- package/src/machine/activity/roulette_activity_v2.js +11 -2
- package/src/machine/activity/sign_in_activity.js +20 -13
- package/src/machine/activity/vip_card_activity.js +140 -0
- package/src/machine/auth.js +54 -5
- package/src/machine/bank_binding.js +112 -12
- package/src/machine/bank_binding_amb.js +6 -1
- package/src/machine/common.js +92 -24
- package/src/machine/deposit/amb.js +5 -3
- package/src/machine/deposit/crypto.js +14 -10
- package/src/machine/deposit/crypto_bank.js +317 -0
- package/src/machine/deposit/crypto_bank_cash.js +280 -0
- package/src/machine/deposit/crypto_button.js +9 -5
- package/src/machine/deposit/crypto_cash.js +2 -5
- package/src/machine/deposit/crypto_qrcode.js +147 -0
- package/src/machine/deposit/crypto_qrcode_cash.js +131 -0
- package/src/machine/deposit/crypto_way.js +220 -0
- package/src/machine/deposit/crypto_way_cash.js +242 -0
- package/src/machine/deposit/direct.js +2 -11
- package/src/machine/deposit/direct_cash.js +6 -26
- package/src/machine/deposit/float.js +5 -3
- package/src/machine/deposit/index.js +14 -0
- package/src/machine/deposit/krway.js +151 -0
- package/src/machine/deposit/loadcard_cash.js +6 -27
- package/src/machine/deposit/loadcard_vn.js +2 -10
- package/src/machine/deposit/manual_cash.js +89 -38
- package/src/machine/deposit/manual_vn.js +104 -48
- package/src/machine/deposit/qrcode_cash.js +12 -23
- package/src/machine/deposit/qrcode_v2.js +3 -8
- package/src/machine/deposit/usdt_cash.js +0 -2
- package/src/machine/deposit/vpay.js +5 -3
- package/src/machine/game_info.js +57 -0
- package/src/machine/game_search_cash.js +137 -12
- package/src/machine/game_search_v2.js +4 -4
- package/src/machine/game_v2_1.js +131 -7
- package/src/machine/honor_board_cash.js +63 -0
- package/src/machine/inbox.js +259 -34
- package/src/machine/index.js +6 -0
- package/src/machine/leaderboard.js +31 -8
- package/src/machine/reward_cash.js +1 -1
- package/src/machine/side_v2.js +1 -1
- package/src/machine/user_photo.js +65 -0
- package/src/machine/user_sign_up.js +71 -7
- package/src/machine/withdraw/index.js +6 -0
- package/src/machine/withdraw/withdraw_crypto.js +1 -66
- package/src/machine/withdraw/withdraw_crypto2.js +540 -0
- package/src/machine/withdraw/withdraw_krway.js +207 -0
- package/src/machine/withdraw/withdraw_manual.js +595 -0
- package/src/machine/withdraw/withdraw_manual_cash.js +44 -14
- package/src/machine/withdraw/withdraw_vn.js +42 -7
- package/src/machine/withdraw/withdraw_vn2.js +64 -37
- package/src/util/constant.js +18 -0
- package/src/util/deviceToken.js +2 -2
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
import { assign, createMachine } from 'xstate'
|
|
2
|
+
import padStart from 'lodash/padStart.js'
|
|
3
|
+
import payment from '@jetthai/cuora/src/api/payment.js'
|
|
4
|
+
|
|
5
|
+
export default function (request) {
|
|
6
|
+
const { appSecret } = request.config
|
|
7
|
+
return createMachine(
|
|
8
|
+
{
|
|
9
|
+
id: 'crypto_bank',
|
|
10
|
+
initial: 'loading',
|
|
11
|
+
context: {
|
|
12
|
+
paymentDetails: [],
|
|
13
|
+
|
|
14
|
+
cryptos: [],
|
|
15
|
+
addresses: [],
|
|
16
|
+
cryptoBank: null,
|
|
17
|
+
|
|
18
|
+
amount: null,
|
|
19
|
+
selectedCrypto: null,
|
|
20
|
+
selectedAddress: null,
|
|
21
|
+
selectedBank: null,
|
|
22
|
+
|
|
23
|
+
currentCategory: 'cryptoBank',
|
|
24
|
+
currentPayment: null,
|
|
25
|
+
|
|
26
|
+
calculation: null,
|
|
27
|
+
processing: null,
|
|
28
|
+
result: null,
|
|
29
|
+
|
|
30
|
+
depositTime: null,
|
|
31
|
+
receipt: null,
|
|
32
|
+
proofOptional: false,
|
|
33
|
+
|
|
34
|
+
// use for wallet mode 4
|
|
35
|
+
promotion: null,
|
|
36
|
+
},
|
|
37
|
+
states: {
|
|
38
|
+
loading: {
|
|
39
|
+
initial: 'init1',
|
|
40
|
+
states: {
|
|
41
|
+
init1: {
|
|
42
|
+
invoke: {
|
|
43
|
+
src: 'fetchPayments',
|
|
44
|
+
onDone: {
|
|
45
|
+
target: 'init2',
|
|
46
|
+
actions: 'setPayment',
|
|
47
|
+
},
|
|
48
|
+
onError: {
|
|
49
|
+
target: '#crypto_bank.fail',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
init2: {
|
|
54
|
+
always: [
|
|
55
|
+
{
|
|
56
|
+
target: '#crypto_bank.processing',
|
|
57
|
+
cond: 'isProcessing',
|
|
58
|
+
},
|
|
59
|
+
{ target: '#crypto_bank.loaded' },
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
loaded: {
|
|
65
|
+
always: [{ target: 'debouncing', cond: 'isCalculable' }],
|
|
66
|
+
},
|
|
67
|
+
debouncing: {
|
|
68
|
+
after: {
|
|
69
|
+
1000: {
|
|
70
|
+
target: 'calculating',
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
calculating: {
|
|
75
|
+
invoke: {
|
|
76
|
+
src: 'fetchCalculation',
|
|
77
|
+
onDone: {
|
|
78
|
+
target: 'calculated',
|
|
79
|
+
actions: 'setCalculation',
|
|
80
|
+
},
|
|
81
|
+
onError: {
|
|
82
|
+
target: 'loaded',
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
calculated: {
|
|
87
|
+
on: {
|
|
88
|
+
SUBMIT: [
|
|
89
|
+
{
|
|
90
|
+
target: 'pending',
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
target: 'submitting',
|
|
94
|
+
cond: 'isSubmittable',
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
pending: {
|
|
100
|
+
on: {
|
|
101
|
+
SUBMIT: {
|
|
102
|
+
target: 'submitting',
|
|
103
|
+
cond: 'isSubmittable',
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
submitting: {
|
|
108
|
+
invoke: {
|
|
109
|
+
src: 'submitDeposit',
|
|
110
|
+
onDone: {
|
|
111
|
+
target: 'submitted',
|
|
112
|
+
actions: 'setResult',
|
|
113
|
+
},
|
|
114
|
+
onError: {
|
|
115
|
+
target: 'loaded',
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
processing: {},
|
|
120
|
+
submitted: {},
|
|
121
|
+
fail: {},
|
|
122
|
+
},
|
|
123
|
+
on: {
|
|
124
|
+
SET_CRYPTO: {
|
|
125
|
+
target: '.loaded',
|
|
126
|
+
actions: 'setCrypto',
|
|
127
|
+
},
|
|
128
|
+
SET_ADDRESS: {
|
|
129
|
+
target: '.loaded',
|
|
130
|
+
actions: 'setAddress',
|
|
131
|
+
},
|
|
132
|
+
SET_AMOUNT: {
|
|
133
|
+
target: '.loaded',
|
|
134
|
+
actions: ['setAmount', 'clearCalculation'],
|
|
135
|
+
},
|
|
136
|
+
SET_PROOF_OPTIONAL: {
|
|
137
|
+
actions: 'setProofOptional',
|
|
138
|
+
},
|
|
139
|
+
CALCULATE: {
|
|
140
|
+
target: '.debouncing',
|
|
141
|
+
actions: 'clearCalculation',
|
|
142
|
+
},
|
|
143
|
+
SET_DEPOSIT_TIME: {
|
|
144
|
+
actions: 'setDepositTime',
|
|
145
|
+
},
|
|
146
|
+
SET_RECEIPT: {
|
|
147
|
+
actions: 'setReceipt',
|
|
148
|
+
},
|
|
149
|
+
SET_PROMOTION: {
|
|
150
|
+
actions: 'setPromotion',
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
actions: {
|
|
156
|
+
setPayment: assign((context, event) => {
|
|
157
|
+
const cryptoBank = event.data.find((element) => element.category === context.currentCategory)
|
|
158
|
+
cryptoBank.banks = (cryptoBank.banks || []).map((crypto) => ({
|
|
159
|
+
...crypto,
|
|
160
|
+
label: crypto.cryptoName,
|
|
161
|
+
value: cryptoBank.method,
|
|
162
|
+
icon: crypto.symbol,
|
|
163
|
+
}))
|
|
164
|
+
const defaultCrypto = []
|
|
165
|
+
cryptoBank.banks?.forEach((bank) => {
|
|
166
|
+
var existingCryptoName = defaultCrypto.find((item) => {
|
|
167
|
+
return item.cryptoName === bank.cryptoName
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
if (!existingCryptoName) {
|
|
171
|
+
defaultCrypto.push(bank)
|
|
172
|
+
}
|
|
173
|
+
})
|
|
174
|
+
const currentPayment = {
|
|
175
|
+
label: defaultCrypto[0]?.network,
|
|
176
|
+
value: defaultCrypto[0]?.network,
|
|
177
|
+
icon: defaultCrypto[0]?.network,
|
|
178
|
+
}
|
|
179
|
+
const defaultAddresses = (cryptoBank.banks || [])
|
|
180
|
+
.filter((element) => element.cryptoName === defaultCrypto[0].cryptoName)
|
|
181
|
+
.map((value, i) => {
|
|
182
|
+
return {
|
|
183
|
+
label: value.address,
|
|
184
|
+
value: value.address,
|
|
185
|
+
icon: null,
|
|
186
|
+
}
|
|
187
|
+
})
|
|
188
|
+
|
|
189
|
+
return {
|
|
190
|
+
cryptos: defaultCrypto,
|
|
191
|
+
addresses: defaultAddresses,
|
|
192
|
+
cryptoBank,
|
|
193
|
+
selectedCrypto: defaultCrypto[0],
|
|
194
|
+
selectedAddress: defaultAddresses[0],
|
|
195
|
+
options: defaultCrypto[0]?.optional,
|
|
196
|
+
currentPayment,
|
|
197
|
+
processing: currentPayment.processing?.[0],
|
|
198
|
+
}
|
|
199
|
+
}),
|
|
200
|
+
setCrypto: assign((context, event) => {
|
|
201
|
+
const { cryptoBank } = context
|
|
202
|
+
const selectedCrypto = cryptoBank.banks.find((bank) => bank.label === event.data.label)
|
|
203
|
+
const addresses = cryptoBank.banks
|
|
204
|
+
.filter((element) => element.cryptoName === selectedCrypto.cryptoName)
|
|
205
|
+
.map((value, i) => {
|
|
206
|
+
return {
|
|
207
|
+
label: value.address,
|
|
208
|
+
value: value.address,
|
|
209
|
+
icon: null,
|
|
210
|
+
}
|
|
211
|
+
})
|
|
212
|
+
return {
|
|
213
|
+
addresses,
|
|
214
|
+
selectedCrypto: selectedCrypto,
|
|
215
|
+
selectedAddress: addresses[0],
|
|
216
|
+
selectedAmount: null,
|
|
217
|
+
calculation: null,
|
|
218
|
+
options: cryptoBank.optional,
|
|
219
|
+
}
|
|
220
|
+
}),
|
|
221
|
+
setAddress: assign((context, event) => {
|
|
222
|
+
const { cryptoBank, selectedCrypto } = context
|
|
223
|
+
const selectedCryptoByAddress = cryptoBank.banks.find((bank) => bank.label === selectedCrypto.label && bank.address === event.data.value)
|
|
224
|
+
return {
|
|
225
|
+
selectedCrypto: selectedCryptoByAddress,
|
|
226
|
+
selectedAddress: event.data,
|
|
227
|
+
}
|
|
228
|
+
}),
|
|
229
|
+
setAmount: assign((context, event) => {
|
|
230
|
+
return {
|
|
231
|
+
amount: event.data,
|
|
232
|
+
}
|
|
233
|
+
}),
|
|
234
|
+
setCalculation: assign((context, event) => {
|
|
235
|
+
return {
|
|
236
|
+
calculation: event.data,
|
|
237
|
+
}
|
|
238
|
+
}),
|
|
239
|
+
clearCalculation: assign((context, event) => {
|
|
240
|
+
return {
|
|
241
|
+
calculation: null,
|
|
242
|
+
}
|
|
243
|
+
}),
|
|
244
|
+
setResult: assign((context, event) => {
|
|
245
|
+
return {
|
|
246
|
+
result: event.data,
|
|
247
|
+
}
|
|
248
|
+
}),
|
|
249
|
+
setProofOptional: assign((context, event) => {
|
|
250
|
+
return {
|
|
251
|
+
proofOptional: event.data,
|
|
252
|
+
}
|
|
253
|
+
}),
|
|
254
|
+
setDepositTime: assign((context, event) => {
|
|
255
|
+
return {
|
|
256
|
+
depositTime: event.data,
|
|
257
|
+
}
|
|
258
|
+
}),
|
|
259
|
+
setReceipt: assign((context, event) => {
|
|
260
|
+
return {
|
|
261
|
+
receipt: event.data,
|
|
262
|
+
}
|
|
263
|
+
}),
|
|
264
|
+
setPromotion: assign((context, event) => {
|
|
265
|
+
const promotion = event.data
|
|
266
|
+
return {
|
|
267
|
+
promotion,
|
|
268
|
+
}
|
|
269
|
+
}),
|
|
270
|
+
},
|
|
271
|
+
guards: {
|
|
272
|
+
isCalculable: (context, event) => {
|
|
273
|
+
const { selectedCrypto, selectedAddress, cryptoBank, amount } = context
|
|
274
|
+
return selectedCrypto && selectedAddress && amount && cryptoBank.minimum <= +amount && +amount <= cryptoBank.maximum
|
|
275
|
+
},
|
|
276
|
+
isSubmittable: (context, event) => {
|
|
277
|
+
const { selectedCrypto, selectedAddress, amount, depositTime, receipt, proofOptional } = context
|
|
278
|
+
return selectedCrypto && selectedAddress && amount && depositTime && (receipt || proofOptional)
|
|
279
|
+
},
|
|
280
|
+
isProcessing: (context, event) => {
|
|
281
|
+
return context.processing
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
services: {
|
|
285
|
+
fetchPayments: async (context, event) => {
|
|
286
|
+
return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
|
|
287
|
+
},
|
|
288
|
+
fetchCalculation: async (context, event) => {
|
|
289
|
+
const { selectedCrypto, amount, promotion } = context
|
|
290
|
+
return await request.send(
|
|
291
|
+
payment.getCryptoDepositExpectedResult({
|
|
292
|
+
method: selectedCrypto.value,
|
|
293
|
+
amount,
|
|
294
|
+
cryptoCurrency: selectedCrypto.symbol,
|
|
295
|
+
promotionsNo: promotion?.activityNo,
|
|
296
|
+
})
|
|
297
|
+
)
|
|
298
|
+
},
|
|
299
|
+
submitDeposit: async (context, event) => {
|
|
300
|
+
const { selectedCrypto, depositTime, receipt, amount, promotion } = context
|
|
301
|
+
return await request.send(
|
|
302
|
+
payment.submitDepositTransactionCryptoBank({
|
|
303
|
+
method: selectedCrypto.value,
|
|
304
|
+
amount: amount,
|
|
305
|
+
cryptoCurrency: selectedCrypto.symbol,
|
|
306
|
+
cryptoNetwork: selectedCrypto.network,
|
|
307
|
+
sourceAddress: selectedCrypto.address,
|
|
308
|
+
promotionsNo: promotion?.activityNo,
|
|
309
|
+
depositTime,
|
|
310
|
+
receipt,
|
|
311
|
+
})
|
|
312
|
+
)
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
}
|
|
316
|
+
)
|
|
317
|
+
}
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import { assign, createMachine } from 'xstate'
|
|
2
|
+
import payment from '@jetthai/cuora/src/api/payment.js'
|
|
3
|
+
import { max } from '../../util/index.js'
|
|
4
|
+
|
|
5
|
+
export default function (request, context) {
|
|
6
|
+
const { paymentDetail = [], promotion, selectedAmount, siteConfig } = context || {}
|
|
7
|
+
return createMachine(
|
|
8
|
+
{
|
|
9
|
+
id: 'crypto_cash',
|
|
10
|
+
initial: 'loading',
|
|
11
|
+
context: {
|
|
12
|
+
paymentDetail,
|
|
13
|
+
promotion,
|
|
14
|
+
selectedAmount,
|
|
15
|
+
siteConfig,
|
|
16
|
+
|
|
17
|
+
cryptos: [],
|
|
18
|
+
addresses: [],
|
|
19
|
+
options: [],
|
|
20
|
+
|
|
21
|
+
cryptoBank: null,
|
|
22
|
+
selectedCrypto: null,
|
|
23
|
+
selectedAddress: null,
|
|
24
|
+
|
|
25
|
+
currentCategory: 'cryptoBank',
|
|
26
|
+
|
|
27
|
+
calculation: null,
|
|
28
|
+
result: null,
|
|
29
|
+
receipt: null,
|
|
30
|
+
},
|
|
31
|
+
states: {
|
|
32
|
+
loading: {
|
|
33
|
+
always: [
|
|
34
|
+
{
|
|
35
|
+
target: 'debouncing',
|
|
36
|
+
actions: 'setInitData',
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
loaded: {},
|
|
41
|
+
debouncing: {
|
|
42
|
+
entry: 'clearCalculation',
|
|
43
|
+
after: {
|
|
44
|
+
1000: [
|
|
45
|
+
{
|
|
46
|
+
target: 'calculating',
|
|
47
|
+
cond: 'isCalculable',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
target: 'loaded',
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
calculating: {
|
|
56
|
+
invoke: {
|
|
57
|
+
src: 'fetchCalculation',
|
|
58
|
+
onDone: {
|
|
59
|
+
target: 'calculated',
|
|
60
|
+
actions: 'setCalculation',
|
|
61
|
+
},
|
|
62
|
+
onError: {
|
|
63
|
+
target: 'calculated',
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
calculated: {
|
|
68
|
+
on: {
|
|
69
|
+
SUBMIT: [
|
|
70
|
+
{
|
|
71
|
+
target: 'submitting',
|
|
72
|
+
cond: 'isSubmittable',
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
submitting: {
|
|
78
|
+
invoke: {
|
|
79
|
+
src: 'submitDeposit',
|
|
80
|
+
onDone: {
|
|
81
|
+
target: 'submitted',
|
|
82
|
+
actions: 'setResult',
|
|
83
|
+
},
|
|
84
|
+
onError: {
|
|
85
|
+
target: 'calculated',
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
submitted: {},
|
|
90
|
+
},
|
|
91
|
+
on: {
|
|
92
|
+
SET_PROMOTION: {
|
|
93
|
+
target: '.debouncing',
|
|
94
|
+
actions: 'setPromotion',
|
|
95
|
+
internal: false,
|
|
96
|
+
},
|
|
97
|
+
SET_CRYPTO: {
|
|
98
|
+
target: '.debouncing',
|
|
99
|
+
actions: 'setCrypto',
|
|
100
|
+
internal: false,
|
|
101
|
+
},
|
|
102
|
+
SET_ADDRESS: {
|
|
103
|
+
target: '.debouncing',
|
|
104
|
+
actions: 'setAddress',
|
|
105
|
+
internal: false,
|
|
106
|
+
},
|
|
107
|
+
SET_AMOUNT: {
|
|
108
|
+
target: '.debouncing',
|
|
109
|
+
actions: 'setAmount',
|
|
110
|
+
internal: false,
|
|
111
|
+
},
|
|
112
|
+
INPUT_AMOUNT: {
|
|
113
|
+
target: '.debouncing',
|
|
114
|
+
actions: 'inputAmount',
|
|
115
|
+
internal: false,
|
|
116
|
+
},
|
|
117
|
+
SET_DEPOSIT_TIME: {
|
|
118
|
+
actions: 'setDepositTime',
|
|
119
|
+
},
|
|
120
|
+
SET_RECEIPT: {
|
|
121
|
+
actions: 'setReceipt',
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
actions: {
|
|
127
|
+
setInitData: assign((context, event) => {
|
|
128
|
+
const { paymentDetail } = context
|
|
129
|
+
const cryptoBank = paymentDetail.find((element) => element.transferType === 'deposit' && element.category === context.currentCategory)
|
|
130
|
+
cryptoBank.banks = (cryptoBank.banks || []).map((crypto) => ({
|
|
131
|
+
...crypto,
|
|
132
|
+
label: crypto.cryptoName,
|
|
133
|
+
value: cryptoBank.method,
|
|
134
|
+
icon: crypto.symbol,
|
|
135
|
+
}))
|
|
136
|
+
const defaultCrypto = []
|
|
137
|
+
cryptoBank.banks?.forEach((bank) => {
|
|
138
|
+
var existingCryptoName = defaultCrypto.find((item) => {
|
|
139
|
+
return item.cryptoName === bank.cryptoName
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
if (!existingCryptoName) {
|
|
143
|
+
defaultCrypto.push(bank)
|
|
144
|
+
}
|
|
145
|
+
})
|
|
146
|
+
const defaultAddresses = (cryptoBank.banks || [])
|
|
147
|
+
.filter((element) => element.cryptoName === defaultCrypto[0].cryptoName)
|
|
148
|
+
.map((value, i) => {
|
|
149
|
+
return {
|
|
150
|
+
label: value.address,
|
|
151
|
+
value: value.address,
|
|
152
|
+
icon: null,
|
|
153
|
+
}
|
|
154
|
+
})
|
|
155
|
+
return {
|
|
156
|
+
cryptos: defaultCrypto,
|
|
157
|
+
addresses: defaultAddresses,
|
|
158
|
+
cryptoBank,
|
|
159
|
+
selectedCrypto: defaultCrypto[0],
|
|
160
|
+
selectedAddress: defaultAddresses[0],
|
|
161
|
+
options: cryptoBank.optional,
|
|
162
|
+
}
|
|
163
|
+
}),
|
|
164
|
+
setCrypto: assign((context, event) => {
|
|
165
|
+
const { cryptoBank } = context
|
|
166
|
+
const selectedCrypto = cryptoBank.banks.find((bank) => bank.label === event.data.label)
|
|
167
|
+
const addresses = cryptoBank.banks
|
|
168
|
+
.filter((element) => element.cryptoName === selectedCrypto.cryptoName)
|
|
169
|
+
.map((value, i) => {
|
|
170
|
+
return {
|
|
171
|
+
label: value.address,
|
|
172
|
+
value: value.address,
|
|
173
|
+
icon: null,
|
|
174
|
+
}
|
|
175
|
+
})
|
|
176
|
+
return {
|
|
177
|
+
addresses,
|
|
178
|
+
selectedCrypto: selectedCrypto,
|
|
179
|
+
selectedAddress: addresses[0],
|
|
180
|
+
selectedAmount: null,
|
|
181
|
+
calculation: null,
|
|
182
|
+
options: cryptoBank.optional,
|
|
183
|
+
}
|
|
184
|
+
}),
|
|
185
|
+
setAddress: assign((context, event) => {
|
|
186
|
+
const { cryptoBank, selectedCrypto } = context
|
|
187
|
+
const selectedCryptoByAddress = cryptoBank.banks.find((bank) => bank.label === selectedCrypto.label && bank.address === event.data.value)
|
|
188
|
+
return {
|
|
189
|
+
selectedCrypto: selectedCryptoByAddress,
|
|
190
|
+
selectedAddress: event.data,
|
|
191
|
+
}
|
|
192
|
+
}),
|
|
193
|
+
setAmount: assign((context, event) => {
|
|
194
|
+
// 現金網可自由填額度,grandTotalEnable 欄位感覺不再需要?
|
|
195
|
+
if (context.cryptoBank?.grandTotalEnable === 1) {
|
|
196
|
+
return { selectedAmount: parseFloat(context.selectedAmount || 0) + parseFloat(event.data) }
|
|
197
|
+
} else {
|
|
198
|
+
return { selectedAmount: event.data }
|
|
199
|
+
}
|
|
200
|
+
}),
|
|
201
|
+
inputAmount: assign((context, event) => {
|
|
202
|
+
return { selectedAmount: event.data }
|
|
203
|
+
}),
|
|
204
|
+
setCalculation: assign((context, event) => {
|
|
205
|
+
return {
|
|
206
|
+
calculation: event.data,
|
|
207
|
+
}
|
|
208
|
+
}),
|
|
209
|
+
clearCalculation: assign((context, event) => {
|
|
210
|
+
return {
|
|
211
|
+
calculation: null,
|
|
212
|
+
}
|
|
213
|
+
}),
|
|
214
|
+
setResult: assign((context, event) => {
|
|
215
|
+
return {
|
|
216
|
+
result: event.data,
|
|
217
|
+
}
|
|
218
|
+
}),
|
|
219
|
+
setPromotion: assign((context, event) => {
|
|
220
|
+
const { cryptoBank, selectedAmount } = context
|
|
221
|
+
const promotion = event.data
|
|
222
|
+
return {
|
|
223
|
+
promotion,
|
|
224
|
+
selectedAmount: max(promotion.minimumAmount, cryptoBank.minimum, selectedAmount, 0),
|
|
225
|
+
calculation: null,
|
|
226
|
+
}
|
|
227
|
+
}),
|
|
228
|
+
setDepositTime: assign((context, event) => {
|
|
229
|
+
return {
|
|
230
|
+
depositTime: event.data,
|
|
231
|
+
}
|
|
232
|
+
}),
|
|
233
|
+
setReceipt: assign((context, event) => {
|
|
234
|
+
return {
|
|
235
|
+
receipt: event.data,
|
|
236
|
+
}
|
|
237
|
+
}),
|
|
238
|
+
},
|
|
239
|
+
guards: {
|
|
240
|
+
isCalculable: (context, event) => {
|
|
241
|
+
const { selectedCrypto, selectedAddress, cryptoBank, selectedAmount } = context
|
|
242
|
+
return selectedCrypto && selectedAddress && selectedAmount && cryptoBank.minimum <= +selectedAmount && +selectedAmount <= cryptoBank.maximum
|
|
243
|
+
},
|
|
244
|
+
isSubmittable: (context, event) => {
|
|
245
|
+
const { selectedCrypto, selectedAddress, selectedAmount, depositTime, receipt, calculation, siteConfig } = context
|
|
246
|
+
const { bankDepositProofIsOptional = '1' } = siteConfig
|
|
247
|
+
return selectedCrypto && selectedAddress && selectedAmount && depositTime && calculation && (receipt || bankDepositProofIsOptional === '0')
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
services: {
|
|
251
|
+
fetchCalculation: async (context, event) => {
|
|
252
|
+
const { selectedCrypto, selectedAmount, promotion } = context
|
|
253
|
+
return await request.send(
|
|
254
|
+
payment.getCryptoDepositExpectedResult({
|
|
255
|
+
method: selectedCrypto.value,
|
|
256
|
+
amount: selectedAmount,
|
|
257
|
+
cryptoCurrency: selectedCrypto.symbol,
|
|
258
|
+
promotionsNo: promotion?.promotionsNo,
|
|
259
|
+
})
|
|
260
|
+
)
|
|
261
|
+
},
|
|
262
|
+
submitDeposit: async (context, event) => {
|
|
263
|
+
const { selectedCrypto, selectedAmount, promotion, depositTime, receipt } = context
|
|
264
|
+
return await request.send(
|
|
265
|
+
payment.submitDepositTransactionCryptoBank({
|
|
266
|
+
method: selectedCrypto.value,
|
|
267
|
+
amount: selectedAmount,
|
|
268
|
+
cryptoCurrency: selectedCrypto.symbol,
|
|
269
|
+
cryptoNetwork: selectedCrypto.network,
|
|
270
|
+
sourceAddress: selectedCrypto.address,
|
|
271
|
+
promotionsNo: promotion?.promotionsNo,
|
|
272
|
+
depositTime,
|
|
273
|
+
receipt,
|
|
274
|
+
})
|
|
275
|
+
)
|
|
276
|
+
},
|
|
277
|
+
},
|
|
278
|
+
}
|
|
279
|
+
)
|
|
280
|
+
}
|
|
@@ -19,6 +19,7 @@ export default function (request) {
|
|
|
19
19
|
options: [],
|
|
20
20
|
sourceAddress: '',
|
|
21
21
|
|
|
22
|
+
selectedChannel: null,
|
|
22
23
|
selectedAmount: null,
|
|
23
24
|
selectedCrypto: null,
|
|
24
25
|
selectedNetwork: null,
|
|
@@ -109,7 +110,7 @@ export default function (request) {
|
|
|
109
110
|
},
|
|
110
111
|
{
|
|
111
112
|
actions: 'setAmount',
|
|
112
|
-
cond:
|
|
113
|
+
cond: 'isFreeWalletMode',
|
|
113
114
|
},
|
|
114
115
|
{
|
|
115
116
|
target: 'debouncing',
|
|
@@ -225,7 +226,7 @@ export default function (request) {
|
|
|
225
226
|
actions: 'setResult',
|
|
226
227
|
},
|
|
227
228
|
onError: {
|
|
228
|
-
target: '
|
|
229
|
+
target: 'loaded',
|
|
229
230
|
},
|
|
230
231
|
},
|
|
231
232
|
},
|
|
@@ -243,12 +244,16 @@ export default function (request) {
|
|
|
243
244
|
return {
|
|
244
245
|
selectedAmount: null,
|
|
245
246
|
calculation: null,
|
|
247
|
+
result: null,
|
|
246
248
|
}
|
|
247
249
|
}),
|
|
248
250
|
setInitData: assign((context, event) => {
|
|
249
251
|
const { siteConfig, paymentDetail } = event.data
|
|
250
|
-
const cryptos =
|
|
251
|
-
|
|
252
|
+
const cryptos =
|
|
253
|
+
paymentDetail
|
|
254
|
+
?.filter((element) => element.category === context.currentCategory)
|
|
255
|
+
?.map((crypto) => ({ ...crypto, label: crypto.channel, value: crypto.method, icon: crypto.channel })) || []
|
|
256
|
+
const currentPayment = cryptos[0]
|
|
252
257
|
const channels = cryptos.map((item, i) => ({ ...item, label: `Channel ${padStart(String(i + 1), 2, '0')}`, icon: 'channel' }))
|
|
253
258
|
const defaultNetworks =
|
|
254
259
|
cryptos[0].networkName.map((value, i) => {
|
|
@@ -306,7 +311,6 @@ export default function (request) {
|
|
|
306
311
|
icon: value,
|
|
307
312
|
}
|
|
308
313
|
}) || []
|
|
309
|
-
|
|
310
314
|
const properties = {
|
|
311
315
|
selectedCrypto: event.data,
|
|
312
316
|
networks,
|
|
@@ -130,7 +130,6 @@ export default function (request, context) {
|
|
|
130
130
|
value: crypto.method,
|
|
131
131
|
icon: crypto.channel,
|
|
132
132
|
}))
|
|
133
|
-
|
|
134
133
|
const defaultNetworks = cryptos[0].networkName.map((value, i) => {
|
|
135
134
|
return {
|
|
136
135
|
label: cryptos[0].networkOptional?.[i],
|
|
@@ -138,7 +137,6 @@ export default function (request, context) {
|
|
|
138
137
|
icon: value,
|
|
139
138
|
}
|
|
140
139
|
})
|
|
141
|
-
|
|
142
140
|
return {
|
|
143
141
|
cryptos,
|
|
144
142
|
networks: defaultNetworks,
|
|
@@ -157,7 +155,6 @@ export default function (request, context) {
|
|
|
157
155
|
icon: value,
|
|
158
156
|
}
|
|
159
157
|
})
|
|
160
|
-
|
|
161
158
|
return {
|
|
162
159
|
networks,
|
|
163
160
|
selectedCrypto: selectedCrypto,
|
|
@@ -204,7 +201,6 @@ export default function (request, context) {
|
|
|
204
201
|
setPromotion: assign((context, event) => {
|
|
205
202
|
const { selectedCrypto, selectedAmount } = context
|
|
206
203
|
const promotion = event.data
|
|
207
|
-
|
|
208
204
|
return {
|
|
209
205
|
promotion,
|
|
210
206
|
selectedAmount: max(promotion.minimumAmount, selectedCrypto.minimum, selectedAmount, 0),
|
|
@@ -241,7 +237,7 @@ export default function (request, context) {
|
|
|
241
237
|
)
|
|
242
238
|
},
|
|
243
239
|
submitDeposit: async (context, event) => {
|
|
244
|
-
const { selectedCrypto, selectedNetwork, calculation, sourceAddress } = context
|
|
240
|
+
const { selectedCrypto, selectedNetwork, calculation, sourceAddress, promotion } = context
|
|
245
241
|
return await request.send(
|
|
246
242
|
payment.submitDepositTransactionCrypto({
|
|
247
243
|
method: selectedCrypto.method,
|
|
@@ -249,6 +245,7 @@ export default function (request, context) {
|
|
|
249
245
|
cryptoCurrency: selectedCrypto.channel,
|
|
250
246
|
cryptoNetwork: selectedNetwork.value,
|
|
251
247
|
sourceAddress: sourceAddress,
|
|
248
|
+
promotionsNo: promotion?.promotionsNo,
|
|
252
249
|
})
|
|
253
250
|
)
|
|
254
251
|
},
|