@jetthai/cuora 1.1.65-doubleWallet-2 → 1.1.65
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 +0 -6
- package/dist/bundle.mjs +533 -701
- package/package.json +1 -1
- package/src/api/payment.js +0 -2
- package/src/machine/activity/activity.js +1 -1
- package/src/machine/deposit/crypto.js +19 -36
- package/src/machine/deposit/crypto_button.js +126 -103
- package/src/machine/deposit/direct.js +7 -69
- package/src/machine/deposit/float.js +27 -94
- package/src/machine/deposit/loadcard_vn.js +146 -114
- package/src/machine/deposit/manual_vn.js +7 -39
- package/src/machine/deposit/qrcode_v2.js +171 -155
- package/src/machine/deposit/vpay.js +26 -89
- package/src/machine/promotions.js +1 -1
package/package.json
CHANGED
package/src/api/payment.js
CHANGED
|
@@ -38,7 +38,6 @@ export default {
|
|
|
38
38
|
checkTransaction: (paymentMethod) => ({ url: `payment/${paymentMethod}/checkTransaction`, method: 'post' }),
|
|
39
39
|
setBonusSetting: ({ bonus }) => ({ url: 'payment/v2/setting', method: 'post', params: { bonus } }),
|
|
40
40
|
getCurrentWithdrawRule: () => ({ url: 'payment/v2/getCurrentWithdrawRule', method: 'get' }),
|
|
41
|
-
getDoubleWalletWithdrawRule: ({ walletType }) => ({ url: 'payment/v2/withdrawRule', method: 'post', params: { walletType } }),
|
|
42
41
|
convertFreeCredit: ({ exchangeType, cryptoNetwork, targetAddress }) => ({
|
|
43
42
|
url: 'payment/v2/convertFreeCredit',
|
|
44
43
|
method: 'post',
|
|
@@ -137,5 +136,4 @@ export default {
|
|
|
137
136
|
}),
|
|
138
137
|
giveUp: () => ({ url: 'payment/v2/bankWallet/promotion/giveUp', method: 'post' }),
|
|
139
138
|
restore: ({ amount }) => ({ url: 'payment/v2/bankWallet/restore', method: 'post', params: { amount } }),
|
|
140
|
-
restore: () => ({ url: 'payment/v2/bankWallet/restore', method: 'post', params: { amount } }),
|
|
141
139
|
}
|
|
@@ -85,7 +85,7 @@ export default function (request) {
|
|
|
85
85
|
setActivityList: assign((context, event) => {
|
|
86
86
|
const noRedActivity = [2, 4, 13, 20, 90, 91, 92]
|
|
87
87
|
const { uidSite } = context
|
|
88
|
-
let list =
|
|
88
|
+
let list = event.data
|
|
89
89
|
list.forEach((activity) => {
|
|
90
90
|
const storageUnread = localStorage.getItem(`unread_${activity.activityNo}_${uidSite}`)
|
|
91
91
|
if (noRedActivity.includes(activity.activityType)) {
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { assign, createMachine } from 'xstate'
|
|
2
2
|
import padStart from 'lodash/padStart.js'
|
|
3
3
|
import payment from '@jetthai/cuora/src/api/payment.js'
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
// const padStart = require('lodash/padStart')
|
|
5
6
|
|
|
6
7
|
export default function (request) {
|
|
7
|
-
const { appSecret } = request.config
|
|
8
8
|
return createMachine(
|
|
9
9
|
{
|
|
10
10
|
id: 'crypto',
|
|
11
11
|
initial: 'loading',
|
|
12
12
|
context: {
|
|
13
|
-
siteConfig: null,
|
|
14
13
|
paymentDetails: [],
|
|
15
14
|
|
|
16
15
|
channels: [],
|
|
@@ -27,17 +26,14 @@ export default function (request) {
|
|
|
27
26
|
|
|
28
27
|
calculation: null,
|
|
29
28
|
result: null,
|
|
30
|
-
|
|
31
|
-
// use for wallet mode 4
|
|
32
|
-
promotion: null,
|
|
33
29
|
},
|
|
34
30
|
states: {
|
|
35
31
|
loading: {
|
|
36
32
|
invoke: {
|
|
37
|
-
src: '
|
|
33
|
+
src: 'fetchPayments',
|
|
38
34
|
onDone: {
|
|
39
35
|
target: 'idle',
|
|
40
|
-
actions: '
|
|
36
|
+
actions: 'setCryptos',
|
|
41
37
|
},
|
|
42
38
|
onError: {
|
|
43
39
|
target: '#crypto.fail',
|
|
@@ -54,6 +50,13 @@ export default function (request) {
|
|
|
54
50
|
},
|
|
55
51
|
},
|
|
56
52
|
},
|
|
53
|
+
// calculable: {
|
|
54
|
+
// on: {
|
|
55
|
+
// CALCULATE: {
|
|
56
|
+
// target: 'calculating',
|
|
57
|
+
// },
|
|
58
|
+
// },
|
|
59
|
+
// },
|
|
57
60
|
calculating: {
|
|
58
61
|
invoke: {
|
|
59
62
|
src: 'fetchCalculation',
|
|
@@ -67,20 +70,6 @@ export default function (request) {
|
|
|
67
70
|
},
|
|
68
71
|
},
|
|
69
72
|
calculated: {
|
|
70
|
-
on: {
|
|
71
|
-
SUBMIT: [
|
|
72
|
-
{
|
|
73
|
-
target: 'pending',
|
|
74
|
-
cond: 'isDoubleWalletMode',
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
target: 'submitting',
|
|
78
|
-
cond: 'isSubmittable',
|
|
79
|
-
},
|
|
80
|
-
],
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
pending: {
|
|
84
73
|
on: {
|
|
85
74
|
SUBMIT: {
|
|
86
75
|
target: 'submitting',
|
|
@@ -123,6 +112,10 @@ export default function (request) {
|
|
|
123
112
|
target: '.idle',
|
|
124
113
|
actions: ['setAmount', 'clearCalculation'],
|
|
125
114
|
},
|
|
115
|
+
// CLEAR_CALCULATION: {
|
|
116
|
+
// target: '.idle',
|
|
117
|
+
// actions: 'clearCalculation',
|
|
118
|
+
// },
|
|
126
119
|
CALCULATE: {
|
|
127
120
|
target: '.debouncing',
|
|
128
121
|
actions: 'clearCalculation',
|
|
@@ -131,9 +124,8 @@ export default function (request) {
|
|
|
131
124
|
},
|
|
132
125
|
{
|
|
133
126
|
actions: {
|
|
134
|
-
|
|
135
|
-
const {
|
|
136
|
-
const cryptos = paymentDetail.map?.((crypto) => ({ ...crypto, label: crypto.channel, value: crypto.method, icon: crypto.channel })) || []
|
|
127
|
+
setCryptos: assign((context, event) => {
|
|
128
|
+
const cryptos = event.data?.map?.((crypto) => ({ ...crypto, label: crypto.channel, value: crypto.method, icon: crypto.channel })) || []
|
|
137
129
|
const currentPayment = cryptos.find((element) => element.category === context.currentCategory)
|
|
138
130
|
const channels = cryptos.map((item, i) => ({ ...item, label: `Channel ${padStart(String(i + 1), 2, '0')}`, icon: 'channel' }))
|
|
139
131
|
const defaultNetworks =
|
|
@@ -145,7 +137,6 @@ export default function (request) {
|
|
|
145
137
|
}
|
|
146
138
|
}) || []
|
|
147
139
|
return {
|
|
148
|
-
siteConfig,
|
|
149
140
|
channels,
|
|
150
141
|
cryptos,
|
|
151
142
|
networks: defaultNetworks,
|
|
@@ -230,9 +221,6 @@ export default function (request) {
|
|
|
230
221
|
}),
|
|
231
222
|
},
|
|
232
223
|
guards: {
|
|
233
|
-
isDoubleWalletMode: (context, event) => {
|
|
234
|
-
return context.siteConfig?.walletMode === '4'
|
|
235
|
-
},
|
|
236
224
|
isCalculable: (context, event) => {
|
|
237
225
|
const {
|
|
238
226
|
selectedCrypto,
|
|
@@ -248,13 +236,8 @@ export default function (request) {
|
|
|
248
236
|
},
|
|
249
237
|
},
|
|
250
238
|
services: {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
request.send(common.getConfig({ appSecret })),
|
|
254
|
-
request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' })),
|
|
255
|
-
])
|
|
256
|
-
const siteConfig = JSON.parse(window.atob(config))
|
|
257
|
-
return { siteConfig, paymentDetail }
|
|
239
|
+
fetchPayments: async (context, event) => {
|
|
240
|
+
return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
|
|
258
241
|
},
|
|
259
242
|
fetchCalculation: async (context, event) => {
|
|
260
243
|
const { selectedCrypto, amount } = context
|
|
@@ -30,18 +30,14 @@ export default function (request) {
|
|
|
30
30
|
result: null,
|
|
31
31
|
|
|
32
32
|
grandTotalEnable: 1,
|
|
33
|
-
|
|
34
|
-
// use for wallet mode 4
|
|
35
|
-
promotion: null,
|
|
36
|
-
bonusPreviewData: [],
|
|
37
33
|
},
|
|
38
34
|
states: {
|
|
39
35
|
loading: {
|
|
40
36
|
invoke: {
|
|
41
37
|
src: 'fetchInitData',
|
|
42
38
|
onDone: {
|
|
43
|
-
target: '
|
|
44
|
-
actions: 'setInitData',
|
|
39
|
+
target: 'checking',
|
|
40
|
+
actions: ['setInitData', 'preset'],
|
|
45
41
|
},
|
|
46
42
|
onError: {
|
|
47
43
|
target: 'fail',
|
|
@@ -49,31 +45,116 @@ export default function (request) {
|
|
|
49
45
|
},
|
|
50
46
|
},
|
|
51
47
|
checking: {
|
|
52
|
-
always: [
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
48
|
+
always: [{ target: 'newWalletMode', cond: 'isNewWalletMode' }, { target: 'defaultMode' }],
|
|
49
|
+
},
|
|
50
|
+
newWalletMode: {
|
|
51
|
+
initial: 'loaded',
|
|
52
|
+
states: {
|
|
53
|
+
loaded: {
|
|
54
|
+
entry: 'reset',
|
|
55
|
+
on: {
|
|
56
|
+
SET_CHANNEL: {
|
|
57
|
+
actions: 'setChannel',
|
|
58
|
+
},
|
|
59
|
+
SET_CRYPTO: {
|
|
60
|
+
actions: 'setCrypto',
|
|
61
|
+
},
|
|
62
|
+
SET_NETWORK: {
|
|
63
|
+
actions: 'setNetwork',
|
|
64
|
+
},
|
|
65
|
+
SET_ADDRESS: {
|
|
66
|
+
actions: 'setAddress',
|
|
67
|
+
},
|
|
68
|
+
CONFIRM: {
|
|
69
|
+
target: 'selecting',
|
|
70
|
+
cond: 'isConfirmable',
|
|
71
|
+
},
|
|
59
72
|
},
|
|
60
73
|
},
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
74
|
+
selecting: {
|
|
75
|
+
entry: 'reset',
|
|
76
|
+
on: {
|
|
77
|
+
SELECT_AMOUNT: [
|
|
78
|
+
{
|
|
79
|
+
actions: 'addAmount',
|
|
80
|
+
cond: (context, event) => context.grandTotalEnable === 1,
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
actions: 'setAmount',
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
KEY_IN: {
|
|
87
|
+
actions: 'setAmount',
|
|
88
|
+
},
|
|
89
|
+
SUBMIT: {
|
|
90
|
+
target: 'debouncing',
|
|
91
|
+
},
|
|
92
|
+
BACK: {
|
|
93
|
+
target: 'loaded',
|
|
94
|
+
},
|
|
95
|
+
CLEAR_ALL: {
|
|
96
|
+
actions: 'reset',
|
|
97
|
+
},
|
|
98
|
+
},
|
|
70
99
|
},
|
|
71
|
-
|
|
72
|
-
|
|
100
|
+
debouncing: {
|
|
101
|
+
on: {
|
|
102
|
+
SELECT_AMOUNT: [
|
|
103
|
+
{
|
|
104
|
+
target: 'debouncing',
|
|
105
|
+
actions: 'addAmount',
|
|
106
|
+
cond: (context, event) => context.grandTotalEnable === 1,
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
target: 'debouncing',
|
|
110
|
+
actions: 'setAmount',
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
KEY_IN: {
|
|
114
|
+
target: 'debouncing',
|
|
115
|
+
actions: 'setAmount',
|
|
116
|
+
},
|
|
117
|
+
BACK: {
|
|
118
|
+
target: 'loaded',
|
|
119
|
+
},
|
|
120
|
+
CLEAR_ALL: {
|
|
121
|
+
actions: 'reset',
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
after: {
|
|
125
|
+
1000: {
|
|
126
|
+
target: 'calculating',
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
calculating: {
|
|
131
|
+
invoke: {
|
|
132
|
+
src: 'fetchCalculation',
|
|
133
|
+
onDone: {
|
|
134
|
+
target: 'submitting',
|
|
135
|
+
actions: 'setCalculation',
|
|
136
|
+
},
|
|
137
|
+
onError: {
|
|
138
|
+
target: 'selecting',
|
|
139
|
+
actions: 'reset',
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
submitting: {
|
|
144
|
+
invoke: {
|
|
145
|
+
src: 'submitDeposit',
|
|
146
|
+
onDone: {
|
|
147
|
+
target: '#crypro_button.submitted',
|
|
148
|
+
actions: 'setResult',
|
|
149
|
+
},
|
|
150
|
+
onError: {
|
|
151
|
+
target: 'selecting',
|
|
152
|
+
},
|
|
153
|
+
},
|
|
73
154
|
},
|
|
74
155
|
},
|
|
75
156
|
},
|
|
76
|
-
|
|
157
|
+
defaultMode: {
|
|
77
158
|
on: {
|
|
78
159
|
SET_CHANNEL: {
|
|
79
160
|
actions: 'setChannel',
|
|
@@ -100,45 +181,20 @@ export default function (request) {
|
|
|
100
181
|
SELECT_AMOUNT: [
|
|
101
182
|
{
|
|
102
183
|
target: 'debouncing',
|
|
103
|
-
actions: 'setAmount',
|
|
104
|
-
cond: 'isDoubleWalletMode',
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
184
|
actions: 'addAmount',
|
|
108
|
-
cond: (context, event) => context.
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
actions: 'setAmount',
|
|
112
|
-
cond: (context, event) => context.siteConfig?.walletMode === '2',
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
target: 'debouncing',
|
|
116
|
-
actions: 'addAmount',
|
|
117
|
-
cond: 'isGrandTotalEnable',
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
target: 'debouncing',
|
|
121
|
-
actions: 'setAmount',
|
|
122
|
-
},
|
|
123
|
-
],
|
|
124
|
-
KEY_IN: [
|
|
125
|
-
{
|
|
126
|
-
actions: 'setAmount',
|
|
127
|
-
cond: 'isFreeWalletMode',
|
|
185
|
+
cond: (context, event) => context.grandTotalEnable === 1,
|
|
128
186
|
},
|
|
129
187
|
{
|
|
130
188
|
target: 'debouncing',
|
|
131
189
|
actions: 'setAmount',
|
|
132
190
|
},
|
|
133
191
|
],
|
|
134
|
-
|
|
192
|
+
KEY_IN: {
|
|
135
193
|
target: 'debouncing',
|
|
194
|
+
actions: 'setAmount',
|
|
136
195
|
},
|
|
137
196
|
BACK: {
|
|
138
|
-
target: '
|
|
139
|
-
},
|
|
140
|
-
CLEAR_ALL: {
|
|
141
|
-
actions: 'reset',
|
|
197
|
+
target: 'defaultMode',
|
|
142
198
|
},
|
|
143
199
|
},
|
|
144
200
|
},
|
|
@@ -148,7 +204,7 @@ export default function (request) {
|
|
|
148
204
|
{
|
|
149
205
|
target: 'debouncing',
|
|
150
206
|
actions: 'addAmount',
|
|
151
|
-
cond:
|
|
207
|
+
cond: (context, event) => context.grandTotalEnable === 1,
|
|
152
208
|
},
|
|
153
209
|
{
|
|
154
210
|
target: 'debouncing',
|
|
@@ -169,17 +225,10 @@ export default function (request) {
|
|
|
169
225
|
calculating: {
|
|
170
226
|
invoke: {
|
|
171
227
|
src: 'fetchCalculation',
|
|
172
|
-
onDone:
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
cond: 'isFreeWalletMode',
|
|
177
|
-
},
|
|
178
|
-
{
|
|
179
|
-
target: 'calculated',
|
|
180
|
-
actions: 'setCalculation',
|
|
181
|
-
},
|
|
182
|
-
],
|
|
228
|
+
onDone: {
|
|
229
|
+
target: 'calculated',
|
|
230
|
+
actions: 'setCalculation',
|
|
231
|
+
},
|
|
183
232
|
onError: {
|
|
184
233
|
target: 'selecting',
|
|
185
234
|
actions: 'reset',
|
|
@@ -192,7 +241,7 @@ export default function (request) {
|
|
|
192
241
|
{
|
|
193
242
|
target: 'debouncing',
|
|
194
243
|
actions: 'addAmount',
|
|
195
|
-
cond:
|
|
244
|
+
cond: (context, event) => context.grandTotalEnable === 1,
|
|
196
245
|
},
|
|
197
246
|
{
|
|
198
247
|
target: 'debouncing',
|
|
@@ -231,11 +280,6 @@ export default function (request) {
|
|
|
231
280
|
},
|
|
232
281
|
submitted: {},
|
|
233
282
|
},
|
|
234
|
-
on: {
|
|
235
|
-
SET_PROMOTION: {
|
|
236
|
-
actions: 'setPromotion',
|
|
237
|
-
},
|
|
238
|
-
},
|
|
239
283
|
},
|
|
240
284
|
{
|
|
241
285
|
actions: {
|
|
@@ -246,7 +290,7 @@ export default function (request) {
|
|
|
246
290
|
}
|
|
247
291
|
}),
|
|
248
292
|
setInitData: assign((context, event) => {
|
|
249
|
-
const {
|
|
293
|
+
const { paymentDetail } = event.data
|
|
250
294
|
const cryptos = paymentDetail?.map?.((crypto) => ({ ...crypto, label: crypto.channel, value: crypto.method, icon: crypto.channel })) || []
|
|
251
295
|
const currentPayment = cryptos.find((element) => element.category === context.currentCategory)
|
|
252
296
|
const channels = cryptos.map((item, i) => ({ ...item, label: `Channel ${padStart(String(i + 1), 2, '0')}`, icon: 'channel' }))
|
|
@@ -260,7 +304,6 @@ export default function (request) {
|
|
|
260
304
|
}) || []
|
|
261
305
|
const options = cryptos[0].optional
|
|
262
306
|
return {
|
|
263
|
-
siteConfig,
|
|
264
307
|
channels,
|
|
265
308
|
cryptos,
|
|
266
309
|
networks: defaultNetworks,
|
|
@@ -272,6 +315,12 @@ export default function (request) {
|
|
|
272
315
|
options,
|
|
273
316
|
}
|
|
274
317
|
}),
|
|
318
|
+
preset: assign((context, event) => {
|
|
319
|
+
const { siteConfig } = event.data
|
|
320
|
+
return {
|
|
321
|
+
siteConfig,
|
|
322
|
+
}
|
|
323
|
+
}),
|
|
275
324
|
setChannel: assign((context, event) => {
|
|
276
325
|
const { cryptos } = context
|
|
277
326
|
const selectedCrypto = cryptos.find((crypto) => crypto.method === event.data.value)
|
|
@@ -323,11 +372,6 @@ export default function (request) {
|
|
|
323
372
|
setNetwork: assign((context, event) => {
|
|
324
373
|
return { selectedNetwork: event.data }
|
|
325
374
|
}),
|
|
326
|
-
setBonusPreview: assign((context, event) => {
|
|
327
|
-
return {
|
|
328
|
-
bonusPreviewData: event.data.bonus,
|
|
329
|
-
}
|
|
330
|
-
}),
|
|
331
375
|
addAmount: assign((context, event) => {
|
|
332
376
|
return { selectedAmount: (context.selectedAmount || 0) + event.data }
|
|
333
377
|
}),
|
|
@@ -354,23 +398,11 @@ export default function (request) {
|
|
|
354
398
|
result: event.data,
|
|
355
399
|
}
|
|
356
400
|
}),
|
|
357
|
-
setPromotion: assign((context, event) => {
|
|
358
|
-
const promotion = event.data
|
|
359
|
-
return {
|
|
360
|
-
promotion,
|
|
361
|
-
}
|
|
362
|
-
}),
|
|
363
401
|
},
|
|
364
402
|
guards: {
|
|
365
|
-
|
|
403
|
+
isNewWalletMode: (context, event) => {
|
|
366
404
|
return context.siteConfig?.walletMode === '2'
|
|
367
405
|
},
|
|
368
|
-
isDoubleWalletMode: (context, event) => {
|
|
369
|
-
return context.siteConfig?.walletMode === '4'
|
|
370
|
-
},
|
|
371
|
-
isGrandTotalEnable: (context, event) => {
|
|
372
|
-
return context.grandTotalEnable === 1
|
|
373
|
-
},
|
|
374
406
|
isConfirmable: (context, event) => {
|
|
375
407
|
const { selectedCrypto, selectedNetwork } = context
|
|
376
408
|
return selectedCrypto && selectedNetwork
|
|
@@ -389,26 +421,18 @@ export default function (request) {
|
|
|
389
421
|
const siteConfig = JSON.parse(window.atob(config))
|
|
390
422
|
return { siteConfig, paymentDetail }
|
|
391
423
|
},
|
|
392
|
-
fetchBonusPreview: async (context, event) => {
|
|
393
|
-
const { selectedCrypto, promotion } = context
|
|
394
|
-
return await request.send({
|
|
395
|
-
paymentMethod: selectedCrypto.method,
|
|
396
|
-
promotionsNo: promotion?.activityNo,
|
|
397
|
-
})
|
|
398
|
-
},
|
|
399
424
|
fetchCalculation: async (context, event) => {
|
|
400
|
-
const { selectedCrypto, selectedAmount
|
|
425
|
+
const { selectedCrypto, selectedAmount } = context
|
|
401
426
|
return await request.send(
|
|
402
427
|
payment.getDepositExpectedResult({
|
|
403
428
|
method: selectedCrypto.method,
|
|
404
429
|
amount: selectedAmount,
|
|
405
430
|
cryptoCurrency: selectedCrypto.channel,
|
|
406
|
-
promotionsNo: promotion?.activityNo,
|
|
407
431
|
})
|
|
408
432
|
)
|
|
409
433
|
},
|
|
410
434
|
submitDeposit: async (context, event) => {
|
|
411
|
-
const { selectedCrypto, selectedNetwork, calculation, sourceAddress
|
|
435
|
+
const { selectedCrypto, selectedNetwork, calculation, sourceAddress } = context
|
|
412
436
|
return await request.send(
|
|
413
437
|
payment.submitDepositTransactionCrypto({
|
|
414
438
|
method: selectedCrypto.method,
|
|
@@ -416,7 +440,6 @@ export default function (request) {
|
|
|
416
440
|
cryptoCurrency: selectedCrypto.channel,
|
|
417
441
|
cryptoNetwork: selectedNetwork.value,
|
|
418
442
|
sourceAddress: sourceAddress,
|
|
419
|
-
promotionsNo: promotion?.activityNo,
|
|
420
443
|
})
|
|
421
444
|
)
|
|
422
445
|
},
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import { assign, createMachine } from 'xstate'
|
|
2
2
|
import payment from '../../api/payment.js'
|
|
3
|
-
import common from '../../api/common.js'
|
|
4
3
|
|
|
5
4
|
export default function (request) {
|
|
6
|
-
const { appSecret } = request.config
|
|
7
5
|
return createMachine(
|
|
8
6
|
{
|
|
9
7
|
id: 'direct',
|
|
10
8
|
initial: 'loading',
|
|
11
9
|
context: {
|
|
12
|
-
|
|
13
|
-
paymentDetail: [],
|
|
10
|
+
paymentDetails: [],
|
|
14
11
|
directs: [],
|
|
15
12
|
currentDirect: null,
|
|
16
13
|
banks: [],
|
|
@@ -56,10 +53,6 @@ export default function (request) {
|
|
|
56
53
|
},
|
|
57
54
|
promotion: {
|
|
58
55
|
always: [
|
|
59
|
-
{
|
|
60
|
-
target: 'loaded',
|
|
61
|
-
cond: 'isDoubleWalletMode',
|
|
62
|
-
},
|
|
63
56
|
{
|
|
64
57
|
target: 'calculating',
|
|
65
58
|
actions: 'setPromotionDefaultAmount',
|
|
@@ -86,61 +79,15 @@ export default function (request) {
|
|
|
86
79
|
actions: 'clearCalculation',
|
|
87
80
|
},
|
|
88
81
|
CALCULATE: {
|
|
89
|
-
target: '
|
|
82
|
+
target: 'calculating',
|
|
83
|
+
cond: 'isCalculable',
|
|
90
84
|
},
|
|
91
|
-
SUBMIT: [
|
|
92
|
-
{
|
|
93
|
-
target: 'pending',
|
|
94
|
-
cond: (context, event) => context.siteConfig?.walletMode === '4' && !!context.calculation,
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
target: 'submitting',
|
|
98
|
-
cond: 'isSubmittable',
|
|
99
|
-
},
|
|
100
|
-
],
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
pending: {
|
|
104
|
-
on: {
|
|
105
85
|
SUBMIT: {
|
|
106
86
|
target: 'submitting',
|
|
107
87
|
cond: 'isSubmittable',
|
|
108
88
|
},
|
|
109
89
|
},
|
|
110
90
|
},
|
|
111
|
-
debouncing: {
|
|
112
|
-
on: {
|
|
113
|
-
SELECT_DIRECT: {
|
|
114
|
-
actions: ['setDirect', 'reset'],
|
|
115
|
-
target: 'loading.fetching',
|
|
116
|
-
},
|
|
117
|
-
SELECT_BANK: {
|
|
118
|
-
actions: 'setSelectedBank',
|
|
119
|
-
},
|
|
120
|
-
SET_AMOUNT: {
|
|
121
|
-
actions: ['setAmount', 'clearCalculation'],
|
|
122
|
-
},
|
|
123
|
-
CLEAR_CALCULATION: {
|
|
124
|
-
actions: 'clearCalculation',
|
|
125
|
-
},
|
|
126
|
-
CALCULATE: {
|
|
127
|
-
target: 'debouncing',
|
|
128
|
-
},
|
|
129
|
-
SUBMIT: [
|
|
130
|
-
{
|
|
131
|
-
target: 'pending',
|
|
132
|
-
cond: (context, event) => context.siteConfig?.walletMode === '4' && !!context.calculation,
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
target: 'submitting',
|
|
136
|
-
cond: 'isSubmittable',
|
|
137
|
-
},
|
|
138
|
-
],
|
|
139
|
-
},
|
|
140
|
-
after: {
|
|
141
|
-
1000: [{ target: 'calculating', cond: 'isCalculable' }, { target: 'loaded' }],
|
|
142
|
-
},
|
|
143
|
-
},
|
|
144
91
|
calculating: {
|
|
145
92
|
invoke: {
|
|
146
93
|
src: 'fetchCalculation',
|
|
@@ -185,12 +132,11 @@ export default function (request) {
|
|
|
185
132
|
}
|
|
186
133
|
}),
|
|
187
134
|
setInitData: assign((context, event) => {
|
|
188
|
-
const
|
|
189
|
-
const directs =
|
|
135
|
+
const paymentDetails = event.data
|
|
136
|
+
const directs = paymentDetails.filter((element) => element.category === context.currentCategory)
|
|
190
137
|
|
|
191
138
|
return {
|
|
192
|
-
|
|
193
|
-
paymentDetail,
|
|
139
|
+
paymentDetails,
|
|
194
140
|
directs,
|
|
195
141
|
currentDirect: directs[0],
|
|
196
142
|
currentMethod: directs[0]?.method,
|
|
@@ -247,9 +193,6 @@ export default function (request) {
|
|
|
247
193
|
}),
|
|
248
194
|
},
|
|
249
195
|
guards: {
|
|
250
|
-
isDoubleWalletMode: (context, event) => {
|
|
251
|
-
return context.siteConfig?.walletMode === '4'
|
|
252
|
-
},
|
|
253
196
|
isCalculable: (context, event) => {
|
|
254
197
|
const {
|
|
255
198
|
amount,
|
|
@@ -268,12 +211,7 @@ export default function (request) {
|
|
|
268
211
|
},
|
|
269
212
|
services: {
|
|
270
213
|
fetchInitData: async (context, event) => {
|
|
271
|
-
|
|
272
|
-
request.send(common.getConfig({ appSecret })),
|
|
273
|
-
request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' })),
|
|
274
|
-
])
|
|
275
|
-
const siteConfig = JSON.parse(window.atob(config))
|
|
276
|
-
return { siteConfig, paymentDetail }
|
|
214
|
+
return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
|
|
277
215
|
},
|
|
278
216
|
fetchBanksList: async (context, event) => {
|
|
279
217
|
const { currentDirect } = context
|