@jetthai/cuora 1.0.204 → 1.0.302-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/.husky/pre-commit +4 -0
- package/.prettierignore +1 -0
- package/CHANGELOG.md +848 -0
- package/README.md +6 -0
- package/package.json +6 -9
- package/src/api/activity.js +43 -2
- package/src/api/auth.js +22 -7
- package/src/api/common.js +3 -1
- package/src/api/game.js +20 -7
- package/src/api/mailbox.js +9 -5
- package/src/api/payment.js +167 -19
- package/src/api/user.js +7 -0
- package/src/lib/fingerprint.js +9779 -0
- package/src/machine/activity/activity.js +111 -26
- package/src/machine/activity/activity_cash.js +159 -0
- package/src/machine/activity/cash_rain_activity.js +153 -0
- package/src/machine/activity/continue_deposit_activity.js +11 -2
- package/src/machine/activity/deposit_activity.js +13 -4
- package/src/machine/activity/diamond_shop_activity_cash.js +179 -0
- package/src/machine/activity/diamond_shop_activity_vn.js +54 -89
- package/src/machine/activity/fafafa_activity.js +34 -19
- package/src/machine/activity/{affiliate_invite_friends_activity.js → friend_invite_friends_activity.js} +72 -45
- package/src/machine/activity/index.js +22 -4
- package/src/machine/activity/instant_rebate_activity.js +217 -0
- package/src/machine/activity/invite_friends_activity.js +14 -14
- package/src/machine/activity/jackpot.js +74 -0
- package/src/machine/activity/otp_verified_activity.js +74 -0
- package/src/machine/activity/ranking_activity.js +11 -2
- package/src/machine/activity/roulette_activity_v2.js +90 -0
- package/src/machine/activity/sign_in_activity.js +21 -14
- package/src/machine/activity/sign_in_monthly_activity.js +65 -0
- package/src/machine/activity/specify_bets_activity.js +25 -3
- package/src/machine/activity/specify_turnover_activity.js +25 -3
- package/src/machine/activity/time_bomb_activity.js +11 -2
- package/src/machine/activity/vip_card_activity.js +140 -0
- package/src/machine/auth.js +141 -27
- package/src/machine/auth_otp_v2.js +10 -4
- package/src/machine/auth_otp_v3.js +11 -3
- package/src/machine/bank_binding.js +112 -12
- package/src/machine/bank_binding_amb.js +145 -0
- package/src/machine/common.js +113 -25
- package/src/machine/deposit/amb.js +92 -0
- package/src/machine/deposit/crypto.js +50 -29
- package/src/machine/deposit/crypto_bank.js +317 -0
- package/src/machine/deposit/crypto_bank_cash.js +287 -0
- package/src/machine/deposit/crypto_button.js +174 -39
- package/src/machine/deposit/crypto_cash.js +255 -0
- package/src/machine/deposit/crypto_qrcode.js +148 -0
- package/src/machine/deposit/crypto_qrcode_cash.js +131 -0
- package/src/machine/deposit/crypto_way.js +239 -0
- package/src/machine/deposit/crypto_way_cash.js +256 -0
- package/src/machine/deposit/deposit_fc.js +8 -5
- package/src/machine/deposit/direct.js +111 -16
- package/src/machine/deposit/direct_cash.js +217 -0
- package/src/machine/deposit/float.js +366 -0
- package/src/machine/deposit/index.js +43 -2
- package/src/machine/deposit/krway.js +151 -0
- package/src/machine/deposit/loadcard_cash.js +207 -0
- package/src/machine/deposit/loadcard_vn.js +191 -43
- package/src/machine/deposit/manual_cash.js +356 -0
- package/src/machine/deposit/manual_vn.js +182 -60
- package/src/machine/deposit/qrcode_cash.js +217 -0
- package/src/machine/deposit/qrcode_v2.js +285 -52
- package/src/machine/deposit/usdt.js +144 -0
- package/src/machine/deposit/usdt_cash.js +138 -0
- package/src/machine/deposit/vpay.js +359 -0
- package/src/machine/game_favorite_v2.js +70 -28
- package/src/machine/game_info.js +57 -0
- package/src/machine/game_search_cash.js +390 -0
- package/src/machine/game_search_v2.js +64 -24
- package/src/machine/game_v2_1.js +662 -0
- package/src/machine/honor_board_cash.js +63 -0
- package/src/machine/inbox.js +259 -34
- package/src/machine/index.js +24 -17
- package/src/machine/leaderboard.js +31 -8
- package/src/machine/navbar.js +57 -0
- package/src/machine/promotions.js +171 -0
- package/src/machine/reward.js +74 -7
- package/src/machine/reward_cash.js +219 -0
- package/src/machine/roulette_v2.js +276 -0
- package/src/machine/setting.js +5 -2
- package/src/machine/side_cash.js +110 -0
- package/src/machine/side_v2.js +33 -28
- package/src/machine/user_photo.js +65 -0
- package/src/machine/user_sign_up.js +117 -17
- package/src/machine/withdraw/index.js +23 -0
- package/src/machine/{withdraw_vn.js → withdraw/withdraw_amb.js} +146 -78
- package/src/machine/{withdraw_crypto.js → withdraw/withdraw_crypto.js} +220 -69
- package/src/machine/withdraw/withdraw_crypto2.js +540 -0
- package/src/machine/withdraw/withdraw_crypto_cash.js +319 -0
- package/src/machine/{withdraw_fc.js → withdraw/withdraw_fc.js} +2 -2
- 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 +303 -0
- package/src/machine/withdraw/withdraw_vn.js +533 -0
- package/src/machine/withdraw/withdraw_vn2.js +548 -0
- package/src/request/request.js +10 -5
- package/src/util/constant.js +19 -1
- package/src/util/deviceToken.js +18 -8
- package/src/util/index.js +2 -1
- package/src/util/math.js +4 -0
- package/src/util/storage.js +22 -22
- package/dist/bundle.mjs +0 -18462
- package/rollup.config.js +0 -16
- package/src/machine/auth_otp.js +0 -201
- package/src/machine/deposit/qrcode_vn.js +0 -206
- package/src/machine/game.js +0 -285
- package/src/machine/game_favorite.js +0 -123
- package/src/machine/game_search.js +0 -244
- package/src/machine/game_v2.js +0 -356
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { assign, createMachine } from 'xstate'
|
|
2
|
+
import payment from '../api/payment.js'
|
|
3
|
+
|
|
4
|
+
export default function (request) {
|
|
5
|
+
const { appSecret } = request.config
|
|
6
|
+
|
|
7
|
+
return createMachine(
|
|
8
|
+
{
|
|
9
|
+
id: 'bank_binding_amb',
|
|
10
|
+
initial: 'fetching',
|
|
11
|
+
context: {
|
|
12
|
+
hasAnyAccount: false,
|
|
13
|
+
bankList: [],
|
|
14
|
+
bank: null,
|
|
15
|
+
// bonus: 0,
|
|
16
|
+
bankAccount: null,
|
|
17
|
+
firstNameTh: null,
|
|
18
|
+
lastNameTh: null,
|
|
19
|
+
firstNameEn: null,
|
|
20
|
+
lastNameEn: null,
|
|
21
|
+
},
|
|
22
|
+
states: {
|
|
23
|
+
fetching: {
|
|
24
|
+
invoke: {
|
|
25
|
+
src: 'fetchInitData',
|
|
26
|
+
onDone: {
|
|
27
|
+
target: 'idle',
|
|
28
|
+
actions: 'setBanks',
|
|
29
|
+
},
|
|
30
|
+
onError: {
|
|
31
|
+
target: 'idle',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
idle: {
|
|
36
|
+
on: {
|
|
37
|
+
SET_BANK_CODE: {
|
|
38
|
+
actions: assign((context, event) => {
|
|
39
|
+
return {
|
|
40
|
+
bank: event.data,
|
|
41
|
+
}
|
|
42
|
+
}),
|
|
43
|
+
},
|
|
44
|
+
SET_BANK_ACCOUNT: {
|
|
45
|
+
actions: assign((context, event) => {
|
|
46
|
+
return {
|
|
47
|
+
bankAccount: event.data,
|
|
48
|
+
}
|
|
49
|
+
}),
|
|
50
|
+
},
|
|
51
|
+
SET_FIRST_NAME_TH: {
|
|
52
|
+
actions: assign((context, event) => {
|
|
53
|
+
return {
|
|
54
|
+
firstNameTh: event.data,
|
|
55
|
+
}
|
|
56
|
+
}),
|
|
57
|
+
},
|
|
58
|
+
SET_LAST_NAME_TH: {
|
|
59
|
+
actions: assign((context, event) => {
|
|
60
|
+
return {
|
|
61
|
+
lastNameTh: event.data,
|
|
62
|
+
}
|
|
63
|
+
}),
|
|
64
|
+
},
|
|
65
|
+
SET_FIRST_NAME_EN: {
|
|
66
|
+
actions: assign((context, event) => {
|
|
67
|
+
return {
|
|
68
|
+
firstNameEn: event.data,
|
|
69
|
+
}
|
|
70
|
+
}),
|
|
71
|
+
},
|
|
72
|
+
SET_LAST_NAME_EN: {
|
|
73
|
+
actions: assign((context, event) => {
|
|
74
|
+
return {
|
|
75
|
+
lastNameEn: event.data,
|
|
76
|
+
}
|
|
77
|
+
}),
|
|
78
|
+
},
|
|
79
|
+
BIND_BANK: {
|
|
80
|
+
target: 'binding',
|
|
81
|
+
cond: 'isBindable',
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
binding: {
|
|
86
|
+
invoke: {
|
|
87
|
+
src: 'updatePaymentInfo',
|
|
88
|
+
onDone: {
|
|
89
|
+
target: 'bound',
|
|
90
|
+
},
|
|
91
|
+
onError: {
|
|
92
|
+
target: 'idle',
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
bound: {},
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
actions: {
|
|
101
|
+
setBanks: assign((context, event) => {
|
|
102
|
+
const { bankList = [], paymentInfo = {} } = event.data
|
|
103
|
+
const { bankInfo = [] } = paymentInfo
|
|
104
|
+
return {
|
|
105
|
+
hasAnyAccount: bankInfo.length > 0,
|
|
106
|
+
holderName: bankInfo[0]?.holderName,
|
|
107
|
+
bankList,
|
|
108
|
+
bank: bankList[0],
|
|
109
|
+
}
|
|
110
|
+
}),
|
|
111
|
+
},
|
|
112
|
+
guards: {
|
|
113
|
+
isBindable: (context, event) => {
|
|
114
|
+
const { bank, bankAccount, firstNameTh, lastNameTh, firstNameEn, lastNameEn } = context
|
|
115
|
+
|
|
116
|
+
return bank.bankCode && bankAccount && firstNameTh && lastNameTh && firstNameEn && lastNameEn
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
services: {
|
|
120
|
+
fetchInitData: async (context, event) => {
|
|
121
|
+
const [bankList, paymentInfo] = await Promise.all([
|
|
122
|
+
request.send(payment.getBindingBankList({ appSecret })),
|
|
123
|
+
request.send(payment.getPaymentInfo()),
|
|
124
|
+
])
|
|
125
|
+
return { bankList, paymentInfo }
|
|
126
|
+
},
|
|
127
|
+
updatePaymentInfo: async (context, event) => {
|
|
128
|
+
const { bonus, bank, bankAccount, firstNameTh, lastNameTh, firstNameEn, lastNameEn } = context
|
|
129
|
+
return await request.send(
|
|
130
|
+
payment.updatePaymentInfo({
|
|
131
|
+
paymentProvider: 'amb',
|
|
132
|
+
// bonus,
|
|
133
|
+
bankCode: bank.bankCode,
|
|
134
|
+
bankAccount,
|
|
135
|
+
firstNameTh,
|
|
136
|
+
lastNameTh,
|
|
137
|
+
firstNameEn,
|
|
138
|
+
lastNameEn,
|
|
139
|
+
})
|
|
140
|
+
)
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
}
|
|
144
|
+
)
|
|
145
|
+
}
|
package/src/machine/common.js
CHANGED
|
@@ -29,18 +29,19 @@ export default function (request) {
|
|
|
29
29
|
},
|
|
30
30
|
paymentMethods: {},
|
|
31
31
|
},
|
|
32
|
+
layoutConfig: null,
|
|
32
33
|
userAgent: '',
|
|
33
34
|
isMobile: false,
|
|
34
35
|
announcementList: null,
|
|
35
36
|
broadcastList: null,
|
|
36
37
|
mailBoxInfo: null,
|
|
37
38
|
promotions: [],
|
|
38
|
-
emergencyBroadcast: null,
|
|
39
39
|
normalBroadcast: null,
|
|
40
|
-
sentEmergencyBroadcastList: [],
|
|
41
40
|
sentNormalBroadcastList: [],
|
|
42
41
|
channel: null,
|
|
43
42
|
subchannel: null,
|
|
43
|
+
affiliateCode: null,
|
|
44
|
+
friendCode: null,
|
|
44
45
|
},
|
|
45
46
|
states: {
|
|
46
47
|
config: {
|
|
@@ -54,12 +55,12 @@ export default function (request) {
|
|
|
54
55
|
},
|
|
55
56
|
},
|
|
56
57
|
fetching: {
|
|
57
|
-
entry: ['setUA', 'setAgent'],
|
|
58
|
+
entry: ['setUA', 'setAgent', 'setPixel', 'setKPixel'],
|
|
58
59
|
invoke: {
|
|
59
|
-
src: '
|
|
60
|
+
src: 'fetchConfig',
|
|
60
61
|
onDone: {
|
|
61
62
|
target: 'idle',
|
|
62
|
-
actions: '
|
|
63
|
+
actions: 'setConfig',
|
|
63
64
|
},
|
|
64
65
|
onError: {
|
|
65
66
|
target: 'idle',
|
|
@@ -92,6 +93,30 @@ export default function (request) {
|
|
|
92
93
|
},
|
|
93
94
|
},
|
|
94
95
|
},
|
|
96
|
+
getAnnouncements: {
|
|
97
|
+
initial: 'updating',
|
|
98
|
+
states: {
|
|
99
|
+
updating: {
|
|
100
|
+
invoke: {
|
|
101
|
+
src: 'fetchAnnouncements',
|
|
102
|
+
onDone: {
|
|
103
|
+
target: 'idle',
|
|
104
|
+
actions: 'setAnnouncements',
|
|
105
|
+
},
|
|
106
|
+
onError: {
|
|
107
|
+
target: 'idle',
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
idle: {
|
|
112
|
+
on: {
|
|
113
|
+
FETCH_ANNOUNCEMENTS: {
|
|
114
|
+
target: 'updating',
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
},
|
|
95
120
|
broadcast: {
|
|
96
121
|
initial: 'idle',
|
|
97
122
|
states: {
|
|
@@ -134,10 +159,28 @@ export default function (request) {
|
|
|
134
159
|
},
|
|
135
160
|
},
|
|
136
161
|
actions: {
|
|
137
|
-
|
|
138
|
-
const {
|
|
162
|
+
setConfig: assign((context, event) => {
|
|
163
|
+
const { siteConfig, layoutConfig } = event.data
|
|
164
|
+
const { loginMethods = {}, registerMethods = {} } = siteConfig
|
|
165
|
+
let layoutConfigDecoded = ''
|
|
166
|
+
|
|
167
|
+
if (layoutConfig) {
|
|
168
|
+
const base64Url = layoutConfig.split('.')[0]
|
|
169
|
+
const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/')
|
|
170
|
+
layoutConfigDecoded = decodeURIComponent(
|
|
171
|
+
window
|
|
172
|
+
.atob(base64)
|
|
173
|
+
.split('')
|
|
174
|
+
.map((c) => {
|
|
175
|
+
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)
|
|
176
|
+
})
|
|
177
|
+
.join('')
|
|
178
|
+
)
|
|
179
|
+
layoutConfigDecoded = JSON.parse(layoutConfigDecoded)
|
|
180
|
+
}
|
|
139
181
|
return {
|
|
140
|
-
siteConfig: { ...
|
|
182
|
+
siteConfig: { ...siteConfig, loginMethods: pickBy(loginMethods), registerMethods: pickBy(registerMethods) },
|
|
183
|
+
layoutConfig: layoutConfigDecoded,
|
|
141
184
|
}
|
|
142
185
|
}),
|
|
143
186
|
setUA: assign((context, event) => {
|
|
@@ -148,14 +191,42 @@ export default function (request) {
|
|
|
148
191
|
isMobile: userAgent?.device?.type,
|
|
149
192
|
}
|
|
150
193
|
}),
|
|
194
|
+
setPixel: assign(() => {
|
|
195
|
+
let urlParams = new URLSearchParams(window.location.search)
|
|
196
|
+
const pix = urlParams.get('pix') || storage.get('pix') || ''
|
|
197
|
+
if (pix !== '') {
|
|
198
|
+
storage.set('pix', pix, {
|
|
199
|
+
path: '/',
|
|
200
|
+
maxAge: 60 * 60 * 24 * 7,
|
|
201
|
+
})
|
|
202
|
+
}
|
|
203
|
+
return {
|
|
204
|
+
pix,
|
|
205
|
+
}
|
|
206
|
+
}),
|
|
207
|
+
setKPixel: assign(() => {
|
|
208
|
+
let urlParams = new URLSearchParams(window.location.search)
|
|
209
|
+
const kpix = urlParams.get('kpix') || storage.get('kpix') || ''
|
|
210
|
+
if (kpix !== '') {
|
|
211
|
+
storage.set('kpix', kpix, {
|
|
212
|
+
path: '/',
|
|
213
|
+
maxAge: 60 * 60 * 24 * 7,
|
|
214
|
+
})
|
|
215
|
+
}
|
|
216
|
+
return {
|
|
217
|
+
kpix,
|
|
218
|
+
}
|
|
219
|
+
}),
|
|
151
220
|
setAgent: assign((context, event) => {
|
|
152
221
|
if (window.CC_JSB === true) {
|
|
153
222
|
// is cocos native app
|
|
154
|
-
return
|
|
223
|
+
return
|
|
155
224
|
} else {
|
|
156
225
|
let urlParams = new URLSearchParams(window.location.search)
|
|
157
226
|
const channel = urlParams.get('channel') || storage.get('channel') || defaultChannel || 'official'
|
|
158
227
|
const subchannel = urlParams.get('subchannel') || storage.get('subchannel') || defaultSubchannel || 'pwa'
|
|
228
|
+
const affiliateCode = urlParams.get('ac') || urlParams.get('referralCode') || storage.get('ac') || storage.get('referralCode')
|
|
229
|
+
const friendCode = urlParams.get('fc') || urlParams.get('affiliate') || storage.get('fc') || storage.get('affiliate')
|
|
159
230
|
|
|
160
231
|
storage.set('channel', channel, {
|
|
161
232
|
path: '/',
|
|
@@ -165,58 +236,75 @@ export default function (request) {
|
|
|
165
236
|
path: '/',
|
|
166
237
|
maxAge: 60 * 60 * 24 * 7,
|
|
167
238
|
})
|
|
239
|
+
storage.set('ac', affiliateCode, {
|
|
240
|
+
path: '/',
|
|
241
|
+
maxAge: 60 * 60 * 24 * 7,
|
|
242
|
+
})
|
|
243
|
+
storage.set('fc', friendCode, {
|
|
244
|
+
path: '/',
|
|
245
|
+
maxAge: 60 * 60 * 24 * 7,
|
|
246
|
+
})
|
|
168
247
|
|
|
169
248
|
return {
|
|
170
249
|
channel,
|
|
171
250
|
subchannel,
|
|
251
|
+
affiliateCode,
|
|
252
|
+
friendCode,
|
|
172
253
|
}
|
|
173
254
|
}
|
|
174
255
|
}),
|
|
256
|
+
setAnnouncements: assign((context, event) => {
|
|
257
|
+
const { data } = event.data
|
|
258
|
+
return { announcementList: { data } }
|
|
259
|
+
}),
|
|
175
260
|
setFeeds: assign((context, event) => {
|
|
176
261
|
const { announcementList, broadcastList, mailBoxInfo } = event.data
|
|
177
262
|
const promotions = announcementList?.announcements?.filter?.((item) => item.category === 3) || []
|
|
178
|
-
return {
|
|
263
|
+
return { broadcastList, mailBoxInfo, promotions }
|
|
179
264
|
}),
|
|
180
265
|
setBroadcast: assign((context, event) => {
|
|
181
|
-
const { broadcastList,
|
|
182
|
-
let sentEmergencyList = sentEmergencyBroadcastList
|
|
266
|
+
const { broadcastList, sentNormalBroadcastList, normalBroadcast } = context
|
|
183
267
|
let sentNormalList = sentNormalBroadcastList
|
|
184
|
-
if (emergencyBroadcast) {
|
|
185
|
-
sentEmergencyList = [...sentEmergencyBroadcastList, emergencyBroadcast]
|
|
186
|
-
}
|
|
187
268
|
if (normalBroadcast) {
|
|
188
269
|
sentNormalList = [...sentNormalBroadcastList, normalBroadcast]
|
|
189
270
|
}
|
|
190
|
-
const nextEmergencyBroadcast = broadcastList?.broadcasts?.find((broadcast) => {
|
|
191
|
-
return broadcast.type === '1' && !sentEmergencyList.some((item) => item.broadcast_id === broadcast.broadcast_id)
|
|
192
|
-
})
|
|
193
271
|
const nextNormalBroadcast = broadcastList?.broadcasts?.find((broadcast) => {
|
|
194
272
|
return broadcast.type === '0' && !sentNormalList.some((item) => item.broadcast_id === broadcast.broadcast_id)
|
|
195
273
|
})
|
|
196
274
|
return {
|
|
197
|
-
emergencyBroadcast: nextEmergencyBroadcast,
|
|
198
|
-
sentEmergencyBroadcastList: sentEmergencyList,
|
|
199
275
|
normalBroadcast: nextNormalBroadcast,
|
|
200
276
|
sentNormalBroadcastList: sentNormalList,
|
|
201
277
|
}
|
|
202
278
|
}),
|
|
203
279
|
resetBroadcast: assign((context, event) => {
|
|
204
280
|
return {
|
|
205
|
-
emergencyBroadcast: null,
|
|
206
|
-
sentEmergencyBroadcastList: [],
|
|
207
281
|
normalBroadcast: null,
|
|
208
282
|
sentNormalBroadcastList: [],
|
|
209
283
|
}
|
|
210
284
|
}),
|
|
211
285
|
},
|
|
212
286
|
services: {
|
|
213
|
-
|
|
214
|
-
const
|
|
215
|
-
|
|
287
|
+
fetchConfig: async (context, event) => {
|
|
288
|
+
const [site, layout] = await Promise.all([request.send(api.getConfig({ appSecret })), request.send(api.getLayoutConfig({ appSecret }))])
|
|
289
|
+
const base64Url = site.config.split('.')[0]
|
|
290
|
+
const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/')
|
|
291
|
+
const decodeResult = decodeURIComponent(
|
|
292
|
+
window
|
|
293
|
+
.atob(base64)
|
|
294
|
+
.split('')
|
|
295
|
+
.map((c) => {
|
|
296
|
+
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)
|
|
297
|
+
})
|
|
298
|
+
.join('')
|
|
299
|
+
)
|
|
300
|
+
return { siteConfig: JSON.parse(decodeResult), layoutConfig: layout.config }
|
|
216
301
|
},
|
|
217
302
|
fetchFeeds: async (context, event) => {
|
|
218
303
|
return await request.send(api.feeds({ appSecret }))
|
|
219
304
|
},
|
|
305
|
+
fetchAnnouncements: async (context, event) => {
|
|
306
|
+
return await request.send(api.getAnnouncements({ appSecret }))
|
|
307
|
+
},
|
|
220
308
|
},
|
|
221
309
|
}
|
|
222
310
|
)
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { assign, createMachine } from 'xstate'
|
|
2
|
+
import payment from '../../api/payment.js'
|
|
3
|
+
|
|
4
|
+
export default function (request) {
|
|
5
|
+
return createMachine(
|
|
6
|
+
{
|
|
7
|
+
id: 'amb',
|
|
8
|
+
initial: 'loading',
|
|
9
|
+
context: {
|
|
10
|
+
bankList: [],
|
|
11
|
+
userAccount: {},
|
|
12
|
+
houseAccountName: null,
|
|
13
|
+
houseAccountNumber: null,
|
|
14
|
+
houseBankName: null,
|
|
15
|
+
method: 'amb',
|
|
16
|
+
},
|
|
17
|
+
states: {
|
|
18
|
+
loading: {
|
|
19
|
+
initial: 'checkingUserAccount',
|
|
20
|
+
states: {
|
|
21
|
+
checkingUserAccount: {
|
|
22
|
+
invoke: {
|
|
23
|
+
src: 'fetchPaymentInfo',
|
|
24
|
+
onDone: [
|
|
25
|
+
{
|
|
26
|
+
target: 'initializing',
|
|
27
|
+
actions: 'setUserAccount',
|
|
28
|
+
cond: 'hasUserAccount',
|
|
29
|
+
},
|
|
30
|
+
{ target: '#amb.accountUnbound' },
|
|
31
|
+
],
|
|
32
|
+
onError: {
|
|
33
|
+
target: '#amb.unavailable',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
initializing: {
|
|
38
|
+
invoke: {
|
|
39
|
+
src: 'initialize',
|
|
40
|
+
onDone: { target: '#amb.finish', actions: 'setInitialization' },
|
|
41
|
+
onError: {
|
|
42
|
+
target: '#amb.unavailable',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
finish: {},
|
|
49
|
+
accountUnbound: {},
|
|
50
|
+
unavailable: {},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
actions: {
|
|
55
|
+
setUserAccount: assign((context, event) => {
|
|
56
|
+
return {
|
|
57
|
+
userAccount: event.data?.[0],
|
|
58
|
+
}
|
|
59
|
+
}),
|
|
60
|
+
setInitialization: assign((context, event) => {
|
|
61
|
+
const { houseAccount, bankList } = event.data
|
|
62
|
+
return {
|
|
63
|
+
houseAccountName: houseAccount.accountName,
|
|
64
|
+
houseAccountNumber: houseAccount.accountNumber,
|
|
65
|
+
houseBankName: houseAccount.bankName,
|
|
66
|
+
bankList,
|
|
67
|
+
}
|
|
68
|
+
}),
|
|
69
|
+
},
|
|
70
|
+
guards: {
|
|
71
|
+
hasUserAccount: (context, event) => {
|
|
72
|
+
return event.data?.[0]
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
services: {
|
|
76
|
+
fetchPaymentInfo: async (context, event) => {
|
|
77
|
+
const { bankInfo } = await request.send(payment.getPaymentInfo())
|
|
78
|
+
const filterArray = bankInfo?.filter((item) => item.bindingType !== 'CRYPTO' && item.bindingType !== 'EWALLET')
|
|
79
|
+
return filterArray || []
|
|
80
|
+
},
|
|
81
|
+
initialize: async (context, event) => {
|
|
82
|
+
const { method } = context
|
|
83
|
+
const [houseAccount, bankList] = await Promise.all([
|
|
84
|
+
request.send(payment.submitDepositTransaction({ method })),
|
|
85
|
+
request.send(payment.getBankList(method)),
|
|
86
|
+
])
|
|
87
|
+
return { houseAccount, bankList }
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
}
|
|
91
|
+
)
|
|
92
|
+
}
|
|
@@ -1,15 +1,16 @@
|
|
|
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
|
-
|
|
5
|
-
// const padStart = require('lodash/padStart')
|
|
4
|
+
import common from '../../api/common.js'
|
|
6
5
|
|
|
7
6
|
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,
|
|
13
14
|
paymentDetails: [],
|
|
14
15
|
|
|
15
16
|
channels: [],
|
|
@@ -18,6 +19,7 @@ export default function (request) {
|
|
|
18
19
|
sourceAddress: '',
|
|
19
20
|
|
|
20
21
|
amount: null,
|
|
22
|
+
selectedChannel: null,
|
|
21
23
|
selectedCrypto: null,
|
|
22
24
|
selectedNetwork: null,
|
|
23
25
|
|
|
@@ -26,21 +28,24 @@ export default function (request) {
|
|
|
26
28
|
|
|
27
29
|
calculation: null,
|
|
28
30
|
result: null,
|
|
31
|
+
|
|
32
|
+
// use for wallet mode 4
|
|
33
|
+
promotion: null,
|
|
29
34
|
},
|
|
30
35
|
states: {
|
|
31
36
|
loading: {
|
|
32
37
|
invoke: {
|
|
33
|
-
src: '
|
|
38
|
+
src: 'fetchInitData',
|
|
34
39
|
onDone: {
|
|
35
|
-
target: '
|
|
36
|
-
actions: '
|
|
40
|
+
target: 'loaded',
|
|
41
|
+
actions: 'setInitData',
|
|
37
42
|
},
|
|
38
43
|
onError: {
|
|
39
44
|
target: '#crypto.fail',
|
|
40
45
|
},
|
|
41
46
|
},
|
|
42
47
|
},
|
|
43
|
-
|
|
48
|
+
loaded: {
|
|
44
49
|
always: [{ target: 'debouncing', cond: 'isCalculable' }],
|
|
45
50
|
},
|
|
46
51
|
debouncing: {
|
|
@@ -50,13 +55,6 @@ export default function (request) {
|
|
|
50
55
|
},
|
|
51
56
|
},
|
|
52
57
|
},
|
|
53
|
-
// calculable: {
|
|
54
|
-
// on: {
|
|
55
|
-
// CALCULATE: {
|
|
56
|
-
// target: 'calculating',
|
|
57
|
-
// },
|
|
58
|
-
// },
|
|
59
|
-
// },
|
|
60
58
|
calculating: {
|
|
61
59
|
invoke: {
|
|
62
60
|
src: 'fetchCalculation',
|
|
@@ -65,11 +63,25 @@ export default function (request) {
|
|
|
65
63
|
actions: 'setCalculation',
|
|
66
64
|
},
|
|
67
65
|
onError: {
|
|
68
|
-
target: '
|
|
66
|
+
target: 'loaded',
|
|
69
67
|
},
|
|
70
68
|
},
|
|
71
69
|
},
|
|
72
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: {
|
|
73
85
|
on: {
|
|
74
86
|
SUBMIT: {
|
|
75
87
|
target: 'submitting',
|
|
@@ -85,7 +97,7 @@ export default function (request) {
|
|
|
85
97
|
actions: 'setResult',
|
|
86
98
|
},
|
|
87
99
|
onError: {
|
|
88
|
-
target: '
|
|
100
|
+
target: 'loaded',
|
|
89
101
|
},
|
|
90
102
|
},
|
|
91
103
|
},
|
|
@@ -94,28 +106,24 @@ export default function (request) {
|
|
|
94
106
|
},
|
|
95
107
|
on: {
|
|
96
108
|
SET_CHANNEL: {
|
|
97
|
-
target: '.
|
|
109
|
+
target: '.loaded',
|
|
98
110
|
actions: 'setChannel',
|
|
99
111
|
},
|
|
100
112
|
SET_CRYPTO: {
|
|
101
|
-
target: '.
|
|
113
|
+
target: '.loaded',
|
|
102
114
|
actions: 'setCrypto',
|
|
103
115
|
},
|
|
104
116
|
SET_NETWORK: {
|
|
105
|
-
target: '.
|
|
117
|
+
target: '.loaded',
|
|
106
118
|
actions: 'setNetwork',
|
|
107
119
|
},
|
|
108
120
|
SET_ADDRESS: {
|
|
109
121
|
actions: 'setAddress',
|
|
110
122
|
},
|
|
111
123
|
SET_AMOUNT: {
|
|
112
|
-
target: '.
|
|
124
|
+
target: '.loaded',
|
|
113
125
|
actions: ['setAmount', 'clearCalculation'],
|
|
114
126
|
},
|
|
115
|
-
// CLEAR_CALCULATION: {
|
|
116
|
-
// target: '.idle',
|
|
117
|
-
// actions: 'clearCalculation',
|
|
118
|
-
// },
|
|
119
127
|
CALCULATE: {
|
|
120
128
|
target: '.debouncing',
|
|
121
129
|
actions: 'clearCalculation',
|
|
@@ -124,9 +132,13 @@ export default function (request) {
|
|
|
124
132
|
},
|
|
125
133
|
{
|
|
126
134
|
actions: {
|
|
127
|
-
|
|
128
|
-
const
|
|
129
|
-
const
|
|
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]
|
|
130
142
|
const channels = cryptos.map((item, i) => ({ ...item, label: `Channel ${padStart(String(i + 1), 2, '0')}`, icon: 'channel' }))
|
|
131
143
|
const defaultNetworks =
|
|
132
144
|
cryptos[0].networkName.map((value, i) => {
|
|
@@ -137,6 +149,7 @@ export default function (request) {
|
|
|
137
149
|
}
|
|
138
150
|
}) || []
|
|
139
151
|
return {
|
|
152
|
+
siteConfig,
|
|
140
153
|
channels,
|
|
141
154
|
cryptos,
|
|
142
155
|
networks: defaultNetworks,
|
|
@@ -221,6 +234,9 @@ export default function (request) {
|
|
|
221
234
|
}),
|
|
222
235
|
},
|
|
223
236
|
guards: {
|
|
237
|
+
isDoubleWalletMode: (context, event) => {
|
|
238
|
+
return context.siteConfig?.walletMode === '4'
|
|
239
|
+
},
|
|
224
240
|
isCalculable: (context, event) => {
|
|
225
241
|
const {
|
|
226
242
|
selectedCrypto,
|
|
@@ -236,8 +252,13 @@ export default function (request) {
|
|
|
236
252
|
},
|
|
237
253
|
},
|
|
238
254
|
services: {
|
|
239
|
-
|
|
240
|
-
|
|
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 }
|
|
241
262
|
},
|
|
242
263
|
fetchCalculation: async (context, event) => {
|
|
243
264
|
const { selectedCrypto, amount } = context
|
|
@@ -252,7 +273,7 @@ export default function (request) {
|
|
|
252
273
|
submitDeposit: async (context, event) => {
|
|
253
274
|
const { selectedCrypto, selectedNetwork, calculation, sourceAddress } = context
|
|
254
275
|
return await request.send(
|
|
255
|
-
payment.
|
|
276
|
+
payment.submitDepositTransactionCrypto({
|
|
256
277
|
method: selectedCrypto.method,
|
|
257
278
|
amount: calculation.actualAmount,
|
|
258
279
|
cryptoCurrency: selectedCrypto.channel,
|