@jetthai/cuora 1.1.344 → 1.1.346-dev-1
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 +6 -0
- package/package.json +1 -1
- package/resetGitBranch.sh +62 -0
- package/src/api/activity.js +5 -0
- package/src/api/index.js +2 -1
- package/src/api/ranking.js +26 -0
- package/src/machine/activity/activity.js +0 -4
- package/src/machine/activity/activity_cash.js +0 -4
- package/src/machine/activity/vip_card_activity.js +67 -28
- package/src/machine/deposit/index.js +0 -6
- package/src/machine/dragon_tiger_ranking.js +202 -0
- package/src/machine/index.js +2 -0
- package/src/machine/websocket.js +12 -0
- package/src/machine/deposit/crypto.js +0 -288
- package/src/machine/deposit/crypto_button.js +0 -432
- package/src/machine/deposit/crypto_cash.js +0 -255
|
@@ -1,288 +0,0 @@
|
|
|
1
|
-
import { assign, createMachine } from 'xstate'
|
|
2
|
-
import padStart from 'lodash/padStart.js'
|
|
3
|
-
import payment from '@jetthai/cuora/src/api/payment.js'
|
|
4
|
-
import common from '../../api/common.js'
|
|
5
|
-
|
|
6
|
-
export default function (request) {
|
|
7
|
-
const { appSecret } = request.config
|
|
8
|
-
return createMachine(
|
|
9
|
-
{
|
|
10
|
-
id: 'crypto',
|
|
11
|
-
initial: 'loading',
|
|
12
|
-
context: {
|
|
13
|
-
siteConfig: null,
|
|
14
|
-
paymentDetails: [],
|
|
15
|
-
|
|
16
|
-
channels: [],
|
|
17
|
-
cryptos: [],
|
|
18
|
-
networks: [],
|
|
19
|
-
sourceAddress: '',
|
|
20
|
-
|
|
21
|
-
amount: null,
|
|
22
|
-
selectedChannel: null,
|
|
23
|
-
selectedCrypto: null,
|
|
24
|
-
selectedNetwork: null,
|
|
25
|
-
|
|
26
|
-
currentCategory: 'crypto',
|
|
27
|
-
currentPayment: null,
|
|
28
|
-
|
|
29
|
-
calculation: null,
|
|
30
|
-
result: null,
|
|
31
|
-
|
|
32
|
-
// use for wallet mode 4
|
|
33
|
-
promotion: null,
|
|
34
|
-
},
|
|
35
|
-
states: {
|
|
36
|
-
loading: {
|
|
37
|
-
invoke: {
|
|
38
|
-
src: 'fetchInitData',
|
|
39
|
-
onDone: {
|
|
40
|
-
target: 'loaded',
|
|
41
|
-
actions: 'setInitData',
|
|
42
|
-
},
|
|
43
|
-
onError: {
|
|
44
|
-
target: '#crypto.fail',
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
loaded: {
|
|
49
|
-
always: [{ target: 'debouncing', cond: 'isCalculable' }],
|
|
50
|
-
},
|
|
51
|
-
debouncing: {
|
|
52
|
-
after: {
|
|
53
|
-
1000: {
|
|
54
|
-
target: 'calculating',
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
calculating: {
|
|
59
|
-
invoke: {
|
|
60
|
-
src: 'fetchCalculation',
|
|
61
|
-
onDone: {
|
|
62
|
-
target: 'calculated',
|
|
63
|
-
actions: 'setCalculation',
|
|
64
|
-
},
|
|
65
|
-
onError: {
|
|
66
|
-
target: 'loaded',
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
calculated: {
|
|
71
|
-
on: {
|
|
72
|
-
SUBMIT: [
|
|
73
|
-
{
|
|
74
|
-
target: 'pending',
|
|
75
|
-
cond: 'isDoubleWalletMode',
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
target: 'submitting',
|
|
79
|
-
cond: 'isSubmittable',
|
|
80
|
-
},
|
|
81
|
-
],
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
pending: {
|
|
85
|
-
on: {
|
|
86
|
-
SUBMIT: {
|
|
87
|
-
target: 'submitting',
|
|
88
|
-
cond: 'isSubmittable',
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
submitting: {
|
|
93
|
-
invoke: {
|
|
94
|
-
src: 'submitDeposit',
|
|
95
|
-
onDone: {
|
|
96
|
-
target: 'submitted',
|
|
97
|
-
actions: 'setResult',
|
|
98
|
-
},
|
|
99
|
-
onError: {
|
|
100
|
-
target: 'loaded',
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
submitted: {},
|
|
105
|
-
fail: {},
|
|
106
|
-
},
|
|
107
|
-
on: {
|
|
108
|
-
SET_CHANNEL: {
|
|
109
|
-
target: '.loaded',
|
|
110
|
-
actions: 'setChannel',
|
|
111
|
-
},
|
|
112
|
-
SET_CRYPTO: {
|
|
113
|
-
target: '.loaded',
|
|
114
|
-
actions: 'setCrypto',
|
|
115
|
-
},
|
|
116
|
-
SET_NETWORK: {
|
|
117
|
-
target: '.loaded',
|
|
118
|
-
actions: 'setNetwork',
|
|
119
|
-
},
|
|
120
|
-
SET_ADDRESS: {
|
|
121
|
-
actions: 'setAddress',
|
|
122
|
-
},
|
|
123
|
-
SET_AMOUNT: {
|
|
124
|
-
target: '.loaded',
|
|
125
|
-
actions: ['setAmount', 'clearCalculation'],
|
|
126
|
-
},
|
|
127
|
-
CALCULATE: {
|
|
128
|
-
target: '.debouncing',
|
|
129
|
-
actions: 'clearCalculation',
|
|
130
|
-
},
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
actions: {
|
|
135
|
-
setInitData: assign((context, event) => {
|
|
136
|
-
const { siteConfig, paymentDetail } = event.data
|
|
137
|
-
const cryptos =
|
|
138
|
-
paymentDetail
|
|
139
|
-
.filter((element) => element.category === context.currentCategory)
|
|
140
|
-
.map?.((crypto) => ({ ...crypto, label: crypto.channel, value: crypto.method, icon: crypto.channel })) || []
|
|
141
|
-
const currentPayment = cryptos[0]
|
|
142
|
-
const channels = cryptos.map((item, i) => ({ ...item, label: `Channel ${padStart(String(i + 1), 2, '0')}`, icon: 'channel' }))
|
|
143
|
-
const defaultNetworks =
|
|
144
|
-
cryptos[0].networkName.map((value, i) => {
|
|
145
|
-
return {
|
|
146
|
-
label: cryptos[0].networkOptional?.[i],
|
|
147
|
-
value,
|
|
148
|
-
icon: value,
|
|
149
|
-
}
|
|
150
|
-
}) || []
|
|
151
|
-
return {
|
|
152
|
-
siteConfig,
|
|
153
|
-
channels,
|
|
154
|
-
cryptos,
|
|
155
|
-
networks: defaultNetworks,
|
|
156
|
-
selectedChannel: channels[0],
|
|
157
|
-
selectedCrypto: cryptos[0],
|
|
158
|
-
selectedNetwork: defaultNetworks[0],
|
|
159
|
-
currentPayment,
|
|
160
|
-
}
|
|
161
|
-
}),
|
|
162
|
-
setChannel: assign((context, event) => {
|
|
163
|
-
const { cryptos } = context
|
|
164
|
-
const selectedCrypto = cryptos.find((crypto) => crypto.method === event.data.value)
|
|
165
|
-
const networks =
|
|
166
|
-
selectedCrypto?.networkName.map((value, i) => {
|
|
167
|
-
return {
|
|
168
|
-
label: selectedCrypto?.networkOptional?.[i],
|
|
169
|
-
value,
|
|
170
|
-
icon: value,
|
|
171
|
-
}
|
|
172
|
-
}) || []
|
|
173
|
-
return {
|
|
174
|
-
networks,
|
|
175
|
-
selectedChannel: event.data,
|
|
176
|
-
selectedCrypto: selectedCrypto,
|
|
177
|
-
selectedNetwork: networks[0],
|
|
178
|
-
amount: null,
|
|
179
|
-
calculation: null,
|
|
180
|
-
}
|
|
181
|
-
}),
|
|
182
|
-
setCrypto: assign((context, event) => {
|
|
183
|
-
const { cryptos, selectedNetwork } = context
|
|
184
|
-
const method = cryptos.find((crypto) => crypto.method === event.data.value)
|
|
185
|
-
const networks =
|
|
186
|
-
method?.networkName.map((value, i) => {
|
|
187
|
-
return {
|
|
188
|
-
label: method?.networkOptional?.[i],
|
|
189
|
-
value,
|
|
190
|
-
icon: value,
|
|
191
|
-
}
|
|
192
|
-
}) || []
|
|
193
|
-
|
|
194
|
-
const properties = {
|
|
195
|
-
selectedCrypto: event.data,
|
|
196
|
-
networks,
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
if (!networks.includes(selectedNetwork)) {
|
|
200
|
-
properties.selectedNetwork = null
|
|
201
|
-
properties.amount = null
|
|
202
|
-
properties.calculation = null
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
return properties
|
|
206
|
-
}),
|
|
207
|
-
setNetwork: assign((context, event) => {
|
|
208
|
-
return { selectedNetwork: event.data }
|
|
209
|
-
}),
|
|
210
|
-
setAmount: assign((context, event) => {
|
|
211
|
-
return {
|
|
212
|
-
amount: event.data,
|
|
213
|
-
}
|
|
214
|
-
}),
|
|
215
|
-
setAddress: assign((context, event) => {
|
|
216
|
-
return {
|
|
217
|
-
sourceAddress: event.data,
|
|
218
|
-
}
|
|
219
|
-
}),
|
|
220
|
-
setCalculation: assign((context, event) => {
|
|
221
|
-
return {
|
|
222
|
-
calculation: event.data,
|
|
223
|
-
}
|
|
224
|
-
}),
|
|
225
|
-
clearCalculation: assign((context, event) => {
|
|
226
|
-
return {
|
|
227
|
-
calculation: null,
|
|
228
|
-
}
|
|
229
|
-
}),
|
|
230
|
-
setResult: assign((context, event) => {
|
|
231
|
-
return {
|
|
232
|
-
result: event.data,
|
|
233
|
-
}
|
|
234
|
-
}),
|
|
235
|
-
},
|
|
236
|
-
guards: {
|
|
237
|
-
isDoubleWalletMode: (context, event) => {
|
|
238
|
-
return context.siteConfig?.walletMode === '4'
|
|
239
|
-
},
|
|
240
|
-
isCalculable: (context, event) => {
|
|
241
|
-
const {
|
|
242
|
-
selectedCrypto,
|
|
243
|
-
selectedNetwork,
|
|
244
|
-
amount,
|
|
245
|
-
currentPayment: { maximum, minimum },
|
|
246
|
-
} = context
|
|
247
|
-
return selectedCrypto && selectedNetwork && amount && minimum <= +amount && +amount <= maximum
|
|
248
|
-
},
|
|
249
|
-
isSubmittable: (context, event) => {
|
|
250
|
-
const { selectedCrypto, selectedNetwork, amount } = context
|
|
251
|
-
return selectedCrypto && selectedNetwork && amount
|
|
252
|
-
},
|
|
253
|
-
},
|
|
254
|
-
services: {
|
|
255
|
-
fetchInitData: async (context, event) => {
|
|
256
|
-
const [{ config }, paymentDetail = []] = await Promise.all([
|
|
257
|
-
request.send(common.getConfig({ appSecret })),
|
|
258
|
-
request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' })),
|
|
259
|
-
])
|
|
260
|
-
const siteConfig = JSON.parse(window.atob(config))
|
|
261
|
-
return { siteConfig, paymentDetail }
|
|
262
|
-
},
|
|
263
|
-
fetchCalculation: async (context, event) => {
|
|
264
|
-
const { selectedCrypto, amount } = context
|
|
265
|
-
return await request.send(
|
|
266
|
-
payment.getDepositExpectedResult({
|
|
267
|
-
method: selectedCrypto.method,
|
|
268
|
-
amount,
|
|
269
|
-
cryptoCurrency: selectedCrypto.channel,
|
|
270
|
-
})
|
|
271
|
-
)
|
|
272
|
-
},
|
|
273
|
-
submitDeposit: async (context, event) => {
|
|
274
|
-
const { selectedCrypto, selectedNetwork, calculation, sourceAddress } = context
|
|
275
|
-
return await request.send(
|
|
276
|
-
payment.submitDepositTransactionCrypto({
|
|
277
|
-
method: selectedCrypto.method,
|
|
278
|
-
amount: calculation.actualAmount,
|
|
279
|
-
cryptoCurrency: selectedCrypto.channel,
|
|
280
|
-
cryptoNetwork: selectedNetwork.value,
|
|
281
|
-
sourceAddress: sourceAddress,
|
|
282
|
-
})
|
|
283
|
-
)
|
|
284
|
-
},
|
|
285
|
-
},
|
|
286
|
-
}
|
|
287
|
-
)
|
|
288
|
-
}
|
|
@@ -1,432 +0,0 @@
|
|
|
1
|
-
import { assign, createMachine } from 'xstate'
|
|
2
|
-
import padStart from 'lodash/padStart.js'
|
|
3
|
-
import payment from '../../api/payment.js'
|
|
4
|
-
import common from '../../api/common.js'
|
|
5
|
-
|
|
6
|
-
export default function (request) {
|
|
7
|
-
const { appSecret } = request.config
|
|
8
|
-
return createMachine(
|
|
9
|
-
{
|
|
10
|
-
id: 'crypro_button',
|
|
11
|
-
initial: 'loading',
|
|
12
|
-
context: {
|
|
13
|
-
siteConfig: null,
|
|
14
|
-
paymentDetails: [],
|
|
15
|
-
|
|
16
|
-
channels: [],
|
|
17
|
-
cryptos: [],
|
|
18
|
-
networks: [],
|
|
19
|
-
options: [],
|
|
20
|
-
sourceAddress: '',
|
|
21
|
-
|
|
22
|
-
selectedChannel: null,
|
|
23
|
-
selectedAmount: null,
|
|
24
|
-
selectedCrypto: null,
|
|
25
|
-
selectedNetwork: null,
|
|
26
|
-
|
|
27
|
-
currentCategory: 'crypto',
|
|
28
|
-
currentPayment: null,
|
|
29
|
-
|
|
30
|
-
calculation: null,
|
|
31
|
-
result: null,
|
|
32
|
-
|
|
33
|
-
grandTotalEnable: 1,
|
|
34
|
-
|
|
35
|
-
// use for wallet mode 4
|
|
36
|
-
promotion: null,
|
|
37
|
-
bonusPreviewData: [],
|
|
38
|
-
},
|
|
39
|
-
states: {
|
|
40
|
-
loading: {
|
|
41
|
-
invoke: {
|
|
42
|
-
src: 'fetchInitData',
|
|
43
|
-
onDone: {
|
|
44
|
-
target: 'loaded',
|
|
45
|
-
actions: 'setInitData',
|
|
46
|
-
},
|
|
47
|
-
onError: {
|
|
48
|
-
target: 'fail',
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
checking: {
|
|
53
|
-
always: [
|
|
54
|
-
{
|
|
55
|
-
target: 'fetching',
|
|
56
|
-
cond: (context, event) => {
|
|
57
|
-
const { siteConfig = {}, promotion = {}, selectedCrypto } = context
|
|
58
|
-
const { walletMode = '', bonusPreviewEnable } = siteConfig
|
|
59
|
-
return !!selectedCrypto && walletMode === '4' && bonusPreviewEnable && promotion.activityNo != 'none'
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
{ target: 'loaded' },
|
|
63
|
-
],
|
|
64
|
-
},
|
|
65
|
-
fetching: {
|
|
66
|
-
invoke: {
|
|
67
|
-
src: 'fetchBonusPreview',
|
|
68
|
-
onDone: {
|
|
69
|
-
target: 'loaded',
|
|
70
|
-
actions: 'setBonusPreview',
|
|
71
|
-
},
|
|
72
|
-
onError: {
|
|
73
|
-
target: 'loaded',
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
loaded: {
|
|
78
|
-
on: {
|
|
79
|
-
SET_CHANNEL: {
|
|
80
|
-
actions: 'setChannel',
|
|
81
|
-
},
|
|
82
|
-
SET_CRYPTO: {
|
|
83
|
-
actions: 'setCrypto',
|
|
84
|
-
},
|
|
85
|
-
SET_NETWORK: {
|
|
86
|
-
actions: 'setNetwork',
|
|
87
|
-
},
|
|
88
|
-
SET_ADDRESS: {
|
|
89
|
-
actions: 'setAddress',
|
|
90
|
-
},
|
|
91
|
-
CONFIRM: {
|
|
92
|
-
target: 'selecting',
|
|
93
|
-
cond: 'isConfirmable',
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
fail: {},
|
|
98
|
-
selecting: {
|
|
99
|
-
entry: 'reset',
|
|
100
|
-
on: {
|
|
101
|
-
SELECT_AMOUNT: [
|
|
102
|
-
{
|
|
103
|
-
target: 'debouncing',
|
|
104
|
-
actions: 'setAmount',
|
|
105
|
-
cond: 'isDoubleWalletMode',
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
actions: 'addAmount',
|
|
109
|
-
cond: (context, event) => context.siteConfig?.walletMode === '2' && context.grandTotalEnable === 1,
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
actions: 'setAmount',
|
|
113
|
-
cond: 'isFreeWalletMode',
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
target: 'debouncing',
|
|
117
|
-
actions: 'addAmount',
|
|
118
|
-
cond: 'isGrandTotalEnable',
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
target: 'debouncing',
|
|
122
|
-
actions: 'setAmount',
|
|
123
|
-
},
|
|
124
|
-
],
|
|
125
|
-
KEY_IN: [
|
|
126
|
-
{
|
|
127
|
-
actions: 'setAmount',
|
|
128
|
-
cond: 'isFreeWalletMode',
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
target: 'debouncing',
|
|
132
|
-
actions: 'setAmount',
|
|
133
|
-
},
|
|
134
|
-
],
|
|
135
|
-
SUBMIT: {
|
|
136
|
-
target: 'debouncing',
|
|
137
|
-
},
|
|
138
|
-
BACK: {
|
|
139
|
-
target: 'loaded',
|
|
140
|
-
},
|
|
141
|
-
CLEAR_ALL: {
|
|
142
|
-
actions: 'reset',
|
|
143
|
-
},
|
|
144
|
-
},
|
|
145
|
-
},
|
|
146
|
-
debouncing: {
|
|
147
|
-
on: {
|
|
148
|
-
SELECT_AMOUNT: [
|
|
149
|
-
{
|
|
150
|
-
target: 'debouncing',
|
|
151
|
-
actions: 'addAmount',
|
|
152
|
-
cond: 'isGrandTotalEnable',
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
target: 'debouncing',
|
|
156
|
-
actions: 'setAmount',
|
|
157
|
-
},
|
|
158
|
-
],
|
|
159
|
-
KEY_IN: {
|
|
160
|
-
target: 'debouncing',
|
|
161
|
-
actions: 'setAmount',
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
after: {
|
|
165
|
-
1000: {
|
|
166
|
-
target: 'calculating',
|
|
167
|
-
},
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
calculating: {
|
|
171
|
-
invoke: {
|
|
172
|
-
src: 'fetchCalculation',
|
|
173
|
-
onDone: [
|
|
174
|
-
{
|
|
175
|
-
target: 'submitting',
|
|
176
|
-
actions: 'setCalculation',
|
|
177
|
-
cond: 'isFreeWalletMode',
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
target: 'calculated',
|
|
181
|
-
actions: 'setCalculation',
|
|
182
|
-
},
|
|
183
|
-
],
|
|
184
|
-
onError: {
|
|
185
|
-
target: 'selecting',
|
|
186
|
-
actions: 'reset',
|
|
187
|
-
},
|
|
188
|
-
},
|
|
189
|
-
},
|
|
190
|
-
calculated: {
|
|
191
|
-
on: {
|
|
192
|
-
SELECT_AMOUNT: [
|
|
193
|
-
{
|
|
194
|
-
target: 'debouncing',
|
|
195
|
-
actions: 'addAmount',
|
|
196
|
-
cond: 'isGrandTotalEnable',
|
|
197
|
-
},
|
|
198
|
-
{
|
|
199
|
-
target: 'debouncing',
|
|
200
|
-
actions: 'setAmount',
|
|
201
|
-
},
|
|
202
|
-
],
|
|
203
|
-
KEY_IN: {
|
|
204
|
-
target: 'debouncing',
|
|
205
|
-
actions: 'setAmount',
|
|
206
|
-
},
|
|
207
|
-
SUBMIT: {
|
|
208
|
-
target: 'submitting',
|
|
209
|
-
cond: 'isSubmittable',
|
|
210
|
-
},
|
|
211
|
-
CLEAR_CALCULATION: {
|
|
212
|
-
target: 'debouncing',
|
|
213
|
-
actions: 'clearCalculation',
|
|
214
|
-
},
|
|
215
|
-
CLEAR_ALL: {
|
|
216
|
-
target: 'selecting',
|
|
217
|
-
actions: 'reset',
|
|
218
|
-
},
|
|
219
|
-
},
|
|
220
|
-
},
|
|
221
|
-
submitting: {
|
|
222
|
-
invoke: {
|
|
223
|
-
src: 'submitDeposit',
|
|
224
|
-
onDone: {
|
|
225
|
-
target: 'submitted',
|
|
226
|
-
actions: 'setResult',
|
|
227
|
-
},
|
|
228
|
-
onError: {
|
|
229
|
-
target: 'loaded',
|
|
230
|
-
},
|
|
231
|
-
},
|
|
232
|
-
},
|
|
233
|
-
submitted: {},
|
|
234
|
-
},
|
|
235
|
-
on: {
|
|
236
|
-
SET_PROMOTION: {
|
|
237
|
-
actions: 'setPromotion',
|
|
238
|
-
},
|
|
239
|
-
},
|
|
240
|
-
},
|
|
241
|
-
{
|
|
242
|
-
actions: {
|
|
243
|
-
reset: assign((context, event) => {
|
|
244
|
-
return {
|
|
245
|
-
selectedAmount: null,
|
|
246
|
-
calculation: null,
|
|
247
|
-
result: null,
|
|
248
|
-
}
|
|
249
|
-
}),
|
|
250
|
-
setInitData: assign((context, event) => {
|
|
251
|
-
const { siteConfig, paymentDetail } = event.data
|
|
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]
|
|
257
|
-
const channels = cryptos.map((item, i) => ({ ...item, label: `Channel ${padStart(String(i + 1), 2, '0')}`, icon: 'channel' }))
|
|
258
|
-
const defaultNetworks =
|
|
259
|
-
cryptos[0].networkName.map((value, i) => {
|
|
260
|
-
return {
|
|
261
|
-
label: cryptos[0].networkOptional?.[i],
|
|
262
|
-
value,
|
|
263
|
-
icon: value,
|
|
264
|
-
}
|
|
265
|
-
}) || []
|
|
266
|
-
const options = cryptos[0].optional
|
|
267
|
-
return {
|
|
268
|
-
siteConfig,
|
|
269
|
-
channels,
|
|
270
|
-
cryptos,
|
|
271
|
-
networks: defaultNetworks,
|
|
272
|
-
selectedChannel: channels[0],
|
|
273
|
-
selectedCrypto: cryptos[0],
|
|
274
|
-
selectedNetwork: defaultNetworks[0],
|
|
275
|
-
grandTotalEnable: cryptos[0].grandTotalEnable,
|
|
276
|
-
currentPayment,
|
|
277
|
-
options,
|
|
278
|
-
}
|
|
279
|
-
}),
|
|
280
|
-
setChannel: assign((context, event) => {
|
|
281
|
-
const { cryptos } = context
|
|
282
|
-
const selectedCrypto = cryptos.find((crypto) => crypto.method === event.data.value)
|
|
283
|
-
const networks =
|
|
284
|
-
selectedCrypto?.networkName.map((value, i) => {
|
|
285
|
-
return {
|
|
286
|
-
label: selectedCrypto?.networkOptional?.[i],
|
|
287
|
-
value,
|
|
288
|
-
icon: value,
|
|
289
|
-
}
|
|
290
|
-
}) || []
|
|
291
|
-
const options = selectedCrypto.optional
|
|
292
|
-
return {
|
|
293
|
-
networks,
|
|
294
|
-
selectedChannel: event.data,
|
|
295
|
-
selectedCrypto: selectedCrypto,
|
|
296
|
-
selectedNetwork: networks[0],
|
|
297
|
-
selectedAmount: null,
|
|
298
|
-
calculation: null,
|
|
299
|
-
grandTotalEnable: selectedCrypto.grandTotalEnable,
|
|
300
|
-
options,
|
|
301
|
-
}
|
|
302
|
-
}),
|
|
303
|
-
setCrypto: assign((context, event) => {
|
|
304
|
-
const { cryptos, selectedNetwork } = context
|
|
305
|
-
const method = cryptos.find((crypto) => crypto.method === event.data.value)
|
|
306
|
-
const networks =
|
|
307
|
-
method?.networkName.map((value, i) => {
|
|
308
|
-
return {
|
|
309
|
-
label: method?.networkOptional?.[i],
|
|
310
|
-
value,
|
|
311
|
-
icon: value,
|
|
312
|
-
}
|
|
313
|
-
}) || []
|
|
314
|
-
const properties = {
|
|
315
|
-
selectedCrypto: event.data,
|
|
316
|
-
networks,
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
if (!networks.includes(selectedNetwork)) {
|
|
320
|
-
properties.selectedNetwork = null
|
|
321
|
-
properties.selectedAmount = null
|
|
322
|
-
properties.calculation = null
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
return properties
|
|
326
|
-
}),
|
|
327
|
-
setNetwork: assign((context, event) => {
|
|
328
|
-
return { selectedNetwork: event.data }
|
|
329
|
-
}),
|
|
330
|
-
setBonusPreview: assign((context, event) => {
|
|
331
|
-
return {
|
|
332
|
-
bonusPreviewData: event.data,
|
|
333
|
-
}
|
|
334
|
-
}),
|
|
335
|
-
addAmount: assign((context, event) => {
|
|
336
|
-
return { selectedAmount: (context.selectedAmount || 0) + event.data }
|
|
337
|
-
}),
|
|
338
|
-
setAmount: assign((context, event) => {
|
|
339
|
-
return { selectedAmount: event.data }
|
|
340
|
-
}),
|
|
341
|
-
setAddress: assign((context, event) => {
|
|
342
|
-
return {
|
|
343
|
-
sourceAddress: event.data,
|
|
344
|
-
}
|
|
345
|
-
}),
|
|
346
|
-
setCalculation: assign((context, event) => {
|
|
347
|
-
return {
|
|
348
|
-
calculation: event.data,
|
|
349
|
-
}
|
|
350
|
-
}),
|
|
351
|
-
clearCalculation: assign((context, event) => {
|
|
352
|
-
return {
|
|
353
|
-
calculation: null,
|
|
354
|
-
}
|
|
355
|
-
}),
|
|
356
|
-
setResult: assign((context, event) => {
|
|
357
|
-
return {
|
|
358
|
-
result: event.data,
|
|
359
|
-
}
|
|
360
|
-
}),
|
|
361
|
-
setPromotion: assign((context, event) => {
|
|
362
|
-
const promotion = event.data
|
|
363
|
-
return {
|
|
364
|
-
promotion,
|
|
365
|
-
}
|
|
366
|
-
}),
|
|
367
|
-
},
|
|
368
|
-
guards: {
|
|
369
|
-
isFreeWalletMode: (context, event) => {
|
|
370
|
-
return context.siteConfig?.walletMode === '2'
|
|
371
|
-
},
|
|
372
|
-
isDoubleWalletMode: (context, event) => {
|
|
373
|
-
return context.siteConfig?.walletMode === '4'
|
|
374
|
-
},
|
|
375
|
-
isGrandTotalEnable: (context, event) => {
|
|
376
|
-
return context.grandTotalEnable === 1
|
|
377
|
-
},
|
|
378
|
-
isConfirmable: (context, event) => {
|
|
379
|
-
const { selectedCrypto, selectedNetwork } = context
|
|
380
|
-
return selectedCrypto && selectedNetwork
|
|
381
|
-
},
|
|
382
|
-
isSubmittable: (context, event) => {
|
|
383
|
-
const { selectedCrypto, selectedNetwork, selectedAmount } = context
|
|
384
|
-
return selectedCrypto && selectedNetwork && selectedAmount
|
|
385
|
-
},
|
|
386
|
-
},
|
|
387
|
-
services: {
|
|
388
|
-
fetchInitData: async (context, event) => {
|
|
389
|
-
const [{ config }, paymentDetail = []] = await Promise.all([
|
|
390
|
-
request.send(common.getConfig({ appSecret })),
|
|
391
|
-
request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' })),
|
|
392
|
-
])
|
|
393
|
-
const siteConfig = JSON.parse(window.atob(config))
|
|
394
|
-
return { siteConfig, paymentDetail }
|
|
395
|
-
},
|
|
396
|
-
fetchBonusPreview: async (context, event) => {
|
|
397
|
-
const { selectedCrypto, promotion } = context
|
|
398
|
-
return await request.send(
|
|
399
|
-
payment.getBonusPreview({
|
|
400
|
-
method: selectedCrypto.method,
|
|
401
|
-
promotionsNo: promotion?.activityNo,
|
|
402
|
-
})
|
|
403
|
-
)
|
|
404
|
-
},
|
|
405
|
-
fetchCalculation: async (context, event) => {
|
|
406
|
-
const { selectedCrypto, selectedAmount, promotion } = context
|
|
407
|
-
return await request.send(
|
|
408
|
-
payment.getDepositExpectedResult({
|
|
409
|
-
method: selectedCrypto.method,
|
|
410
|
-
amount: selectedAmount,
|
|
411
|
-
cryptoCurrency: selectedCrypto.channel,
|
|
412
|
-
promotionsNo: promotion?.activityNo,
|
|
413
|
-
})
|
|
414
|
-
)
|
|
415
|
-
},
|
|
416
|
-
submitDeposit: async (context, event) => {
|
|
417
|
-
const { selectedCrypto, selectedNetwork, calculation, sourceAddress, promotion } = context
|
|
418
|
-
return await request.send(
|
|
419
|
-
payment.submitDepositTransactionCrypto({
|
|
420
|
-
method: selectedCrypto.method,
|
|
421
|
-
amount: calculation.actualAmount,
|
|
422
|
-
cryptoCurrency: selectedCrypto.channel,
|
|
423
|
-
cryptoNetwork: selectedNetwork.value,
|
|
424
|
-
sourceAddress: sourceAddress,
|
|
425
|
-
promotionsNo: promotion?.activityNo,
|
|
426
|
-
})
|
|
427
|
-
)
|
|
428
|
-
},
|
|
429
|
-
},
|
|
430
|
-
}
|
|
431
|
-
)
|
|
432
|
-
}
|