@jetthai/cuora 1.0.307-dev-2 → 1.1.0
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 +3 -854
- package/README.md +0 -6
- package/dist/bundle.mjs +18461 -0
- package/package.json +9 -6
- package/rollup.config.js +16 -0
- package/src/api/activity.js +2 -43
- package/src/api/auth.js +7 -22
- package/src/api/common.js +1 -3
- package/src/api/game.js +7 -20
- package/src/api/mailbox.js +5 -9
- package/src/api/payment.js +19 -167
- package/src/api/user.js +0 -7
- package/src/machine/activity/activity.js +26 -111
- package/src/machine/activity/{friend_invite_friends_activity.js → affiliate_invite_friends_activity.js} +41 -70
- package/src/machine/activity/continue_deposit_activity.js +2 -11
- package/src/machine/activity/deposit_activity.js +4 -13
- package/src/machine/activity/diamond_shop_activity_vn.js +89 -54
- package/src/machine/activity/fafafa_activity.js +19 -34
- package/src/machine/activity/index.js +4 -22
- package/src/machine/activity/invite_friends_activity.js +14 -14
- package/src/machine/activity/ranking_activity.js +2 -11
- package/src/machine/activity/sign_in_activity.js +14 -21
- package/src/machine/activity/specify_bets_activity.js +3 -25
- package/src/machine/activity/specify_turnover_activity.js +3 -25
- package/src/machine/activity/time_bomb_activity.js +2 -11
- package/src/machine/auth.js +21 -146
- package/src/machine/auth_otp.js +201 -0
- package/src/machine/auth_otp_v2.js +4 -10
- package/src/machine/auth_otp_v3.js +3 -11
- package/src/machine/bank_binding.js +12 -112
- package/src/machine/common.js +25 -113
- package/src/machine/deposit/crypto.js +29 -50
- package/src/machine/deposit/crypto_button.js +39 -174
- package/src/machine/deposit/deposit_fc.js +5 -8
- package/src/machine/deposit/direct.js +16 -111
- package/src/machine/deposit/index.js +2 -43
- package/src/machine/deposit/loadcard_vn.js +43 -191
- package/src/machine/deposit/manual_vn.js +60 -182
- package/src/machine/deposit/qrcode_v2.js +52 -285
- package/src/machine/deposit/qrcode_vn.js +206 -0
- package/src/machine/game.js +285 -0
- package/src/machine/game_favorite.js +123 -0
- package/src/machine/game_favorite_v2.js +28 -74
- package/src/machine/game_search.js +244 -0
- package/src/machine/game_search_v2.js +24 -64
- package/src/machine/game_v2.js +356 -0
- package/src/machine/inbox.js +34 -259
- package/src/machine/index.js +17 -26
- package/src/machine/leaderboard.js +8 -31
- package/src/machine/reward.js +7 -74
- package/src/machine/setting.js +2 -5
- package/src/machine/side_v2.js +28 -33
- package/src/machine/user_sign_up.js +17 -117
- package/src/machine/{withdraw/withdraw_crypto.js → withdraw_crypto.js} +69 -220
- package/src/machine/{withdraw/withdraw_fc.js → withdraw_fc.js} +2 -2
- package/src/machine/{withdraw/withdraw_amb.js → withdraw_vn.js} +78 -146
- package/src/request/request.js +5 -10
- package/src/util/constant.js +1 -19
- package/src/util/deviceToken.js +8 -18
- package/src/util/index.js +1 -2
- package/src/util/storage.js +22 -22
- package/.husky/pre-commit +0 -4
- package/.prettierignore +0 -1
- package/src/lib/fingerprint.js +0 -9779
- package/src/machine/activity/activity_cash.js +0 -159
- package/src/machine/activity/cash_rain_activity.js +0 -153
- package/src/machine/activity/diamond_shop_activity_cash.js +0 -179
- package/src/machine/activity/instant_rebate_activity.js +0 -195
- package/src/machine/activity/jackpot.js +0 -74
- package/src/machine/activity/otp_verified_activity.js +0 -74
- package/src/machine/activity/roulette_activity_v2.js +0 -90
- package/src/machine/activity/sign_in_monthly_activity.js +0 -65
- package/src/machine/activity/vip_card_activity.js +0 -140
- package/src/machine/bank_binding_amb.js +0 -145
- package/src/machine/deposit/amb.js +0 -92
- package/src/machine/deposit/crypto_bank.js +0 -317
- package/src/machine/deposit/crypto_bank_cash.js +0 -287
- package/src/machine/deposit/crypto_cash.js +0 -255
- package/src/machine/deposit/crypto_qrcode.js +0 -148
- package/src/machine/deposit/crypto_qrcode_cash.js +0 -131
- package/src/machine/deposit/crypto_way.js +0 -239
- package/src/machine/deposit/crypto_way_cash.js +0 -256
- package/src/machine/deposit/direct_cash.js +0 -217
- package/src/machine/deposit/float.js +0 -366
- package/src/machine/deposit/krway.js +0 -151
- package/src/machine/deposit/loadcard_cash.js +0 -207
- package/src/machine/deposit/manual_cash.js +0 -356
- package/src/machine/deposit/qrcode_cash.js +0 -217
- package/src/machine/deposit/usdt.js +0 -144
- package/src/machine/deposit/usdt_cash.js +0 -138
- package/src/machine/deposit/vpay.js +0 -359
- package/src/machine/game_info.js +0 -57
- package/src/machine/game_search_cash.js +0 -390
- package/src/machine/game_v2_1.js +0 -662
- package/src/machine/honor_board.js +0 -118
- package/src/machine/honor_board_cash.js +0 -89
- package/src/machine/navbar.js +0 -57
- package/src/machine/promotions.js +0 -171
- package/src/machine/reward_cash.js +0 -219
- package/src/machine/roulette_v2.js +0 -276
- package/src/machine/side_cash.js +0 -110
- package/src/machine/user_photo.js +0 -65
- package/src/machine/withdraw/index.js +0 -23
- package/src/machine/withdraw/withdraw_crypto2.js +0 -540
- package/src/machine/withdraw/withdraw_crypto_cash.js +0 -319
- package/src/machine/withdraw/withdraw_krway.js +0 -220
- package/src/machine/withdraw/withdraw_manual.js +0 -610
- package/src/machine/withdraw/withdraw_manual_cash.js +0 -303
- package/src/machine/withdraw/withdraw_vn.js +0 -546
- package/src/machine/withdraw/withdraw_vn2.js +0 -561
- package/src/util/math.js +0 -4
|
@@ -2,32 +2,17 @@ import { assign, createMachine } from 'xstate'
|
|
|
2
2
|
import payment from '../api/payment.js'
|
|
3
3
|
|
|
4
4
|
export default function (request) {
|
|
5
|
-
const { appSecret } = request.config
|
|
6
|
-
|
|
7
5
|
return createMachine(
|
|
8
6
|
{
|
|
9
7
|
id: 'bank_binding',
|
|
10
8
|
initial: 'fetching',
|
|
11
9
|
context: {
|
|
12
10
|
hasAnyAccount: false,
|
|
13
|
-
|
|
14
|
-
bankList: [],
|
|
15
|
-
cryptoList: [],
|
|
16
|
-
ewalletList: [],
|
|
17
|
-
},
|
|
18
|
-
currency: null,
|
|
19
|
-
bindingType: 'BANK',
|
|
11
|
+
bankList: [],
|
|
20
12
|
bank: null,
|
|
21
|
-
ifscCode: null,
|
|
22
|
-
crypto: null,
|
|
23
|
-
network: null,
|
|
24
|
-
cryptoAddress: null,
|
|
25
|
-
walletCode: null,
|
|
26
13
|
branch: null,
|
|
27
|
-
branchCode: null,
|
|
28
14
|
accountNumber: null,
|
|
29
15
|
holderName: null,
|
|
30
|
-
pixType: null,
|
|
31
16
|
},
|
|
32
17
|
states: {
|
|
33
18
|
fetching: {
|
|
@@ -44,13 +29,6 @@ export default function (request) {
|
|
|
44
29
|
},
|
|
45
30
|
idle: {
|
|
46
31
|
on: {
|
|
47
|
-
SET_BIND_TYPE: {
|
|
48
|
-
actions: assign((context, event) => {
|
|
49
|
-
return {
|
|
50
|
-
bindingType: event.data,
|
|
51
|
-
}
|
|
52
|
-
}),
|
|
53
|
-
},
|
|
54
32
|
SET_BANK_CODE: {
|
|
55
33
|
actions: assign((context, event) => {
|
|
56
34
|
return {
|
|
@@ -58,34 +36,6 @@ export default function (request) {
|
|
|
58
36
|
}
|
|
59
37
|
}),
|
|
60
38
|
},
|
|
61
|
-
SET_CRYPTO_CODE: {
|
|
62
|
-
actions: assign((context, event) => {
|
|
63
|
-
return {
|
|
64
|
-
crypto: event.data,
|
|
65
|
-
}
|
|
66
|
-
}),
|
|
67
|
-
},
|
|
68
|
-
SET_NETWORK_CODE: {
|
|
69
|
-
actions: assign((context, event) => {
|
|
70
|
-
return {
|
|
71
|
-
network: event.data,
|
|
72
|
-
}
|
|
73
|
-
}),
|
|
74
|
-
},
|
|
75
|
-
SET_CRYPTO_ADDRESS: {
|
|
76
|
-
actions: assign((context, event) => {
|
|
77
|
-
return {
|
|
78
|
-
cryptoAddress: event.data,
|
|
79
|
-
}
|
|
80
|
-
}),
|
|
81
|
-
},
|
|
82
|
-
SET_WALLET_CODE: {
|
|
83
|
-
actions: assign((context, event) => {
|
|
84
|
-
return {
|
|
85
|
-
walletCode: event.data,
|
|
86
|
-
}
|
|
87
|
-
}),
|
|
88
|
-
},
|
|
89
39
|
SET_BRANCH: {
|
|
90
40
|
actions: assign((context, event) => {
|
|
91
41
|
return {
|
|
@@ -93,13 +43,6 @@ export default function (request) {
|
|
|
93
43
|
}
|
|
94
44
|
}),
|
|
95
45
|
},
|
|
96
|
-
SET_BRANCH_CODE: {
|
|
97
|
-
actions: assign((context, event) => {
|
|
98
|
-
return {
|
|
99
|
-
branchCode: event.data,
|
|
100
|
-
}
|
|
101
|
-
}),
|
|
102
|
-
},
|
|
103
46
|
SET_ACCOUNT_NUMBER: {
|
|
104
47
|
actions: assign((context, event) => {
|
|
105
48
|
return {
|
|
@@ -114,20 +57,6 @@ export default function (request) {
|
|
|
114
57
|
}
|
|
115
58
|
}),
|
|
116
59
|
},
|
|
117
|
-
SET_PIX_TYPE: {
|
|
118
|
-
actions: assign((context, event) => {
|
|
119
|
-
return {
|
|
120
|
-
pixType: event.data,
|
|
121
|
-
}
|
|
122
|
-
}),
|
|
123
|
-
},
|
|
124
|
-
SET_IFSC_CODE: {
|
|
125
|
-
actions: assign((context, event) => {
|
|
126
|
-
return {
|
|
127
|
-
ifscCode: event.data,
|
|
128
|
-
}
|
|
129
|
-
}),
|
|
130
|
-
},
|
|
131
60
|
BIND_BANK: {
|
|
132
61
|
target: 'binding',
|
|
133
62
|
cond: 'isBindable',
|
|
@@ -151,66 +80,37 @@ export default function (request) {
|
|
|
151
80
|
{
|
|
152
81
|
actions: {
|
|
153
82
|
setBanks: assign((context, event) => {
|
|
154
|
-
const {
|
|
83
|
+
const { bankList = [], paymentInfo = {} } = event.data
|
|
155
84
|
const { bankInfo = [] } = paymentInfo
|
|
156
85
|
return {
|
|
157
86
|
hasAnyAccount: bankInfo.length > 0,
|
|
158
87
|
holderName: bankInfo[0]?.holderName,
|
|
159
|
-
|
|
160
|
-
bank:
|
|
88
|
+
bankList,
|
|
89
|
+
bank: bankList[0],
|
|
161
90
|
}
|
|
162
91
|
}),
|
|
163
92
|
},
|
|
164
93
|
guards: {
|
|
165
94
|
isBindable: (context, event) => {
|
|
166
|
-
const {
|
|
167
|
-
|
|
168
|
-
if (bindingType === 'CRYPTO') {
|
|
169
|
-
// 虛擬貨幣
|
|
170
|
-
const { crypto, network, cryptoAddress, holderName } = context
|
|
171
|
-
return crypto && network && cryptoAddress && holderName
|
|
172
|
-
} else if (bindingType === 'EWALLET') {
|
|
173
|
-
// 電子錢包
|
|
174
|
-
const { walletCode, accountNumber, holderName } = context
|
|
175
|
-
return walletCode?.bankCode && accountNumber && holderName
|
|
176
|
-
} else {
|
|
177
|
-
// 一般銀行
|
|
178
|
-
if (currency === 'INR') {
|
|
179
|
-
// 如果是印度幣別
|
|
180
|
-
const { bank, ifscCode, accountNumber, branch, holderName } = context
|
|
181
|
-
return bank.bankCode && ifscCode && accountNumber && branch && holderName
|
|
182
|
-
} else {
|
|
183
|
-
const { bank, accountNumber, branch, holderName } = context
|
|
184
|
-
return bank.bankCode && accountNumber && branch && holderName
|
|
185
|
-
}
|
|
186
|
-
}
|
|
95
|
+
const { bank, accountNumber, branch, holderName } = context
|
|
96
|
+
return bank.bankCode && accountNumber && branch && holderName
|
|
187
97
|
},
|
|
188
98
|
},
|
|
189
99
|
services: {
|
|
190
100
|
fetchInitData: async (context, event) => {
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
return { paymentList, paymentInfo }
|
|
101
|
+
const paymentDetail = await request.send(payment.getPaymentDetail({ transferType: 'WITHDRAW' }))
|
|
102
|
+
const method = paymentDetail.find((payment) => payment.category === 'manual').method
|
|
103
|
+
const [bankList, paymentInfo] = await Promise.all([request.send(payment.getBankList(method)), request.send(payment.getPaymentInfo())])
|
|
104
|
+
return { bankList, paymentInfo }
|
|
196
105
|
},
|
|
197
106
|
updatePaymentInfo: async (context, event) => {
|
|
198
|
-
const {
|
|
199
|
-
context
|
|
107
|
+
const { bank, branch, accountNumber, holderName } = context
|
|
200
108
|
return await request.send(
|
|
201
109
|
payment.updatePaymentInfo({
|
|
202
|
-
|
|
203
|
-
ifscCode,
|
|
204
|
-
bankCode: bank?.bankCode || '',
|
|
205
|
-
cryptoCurrency: crypto?.symbol || '',
|
|
206
|
-
cryptoNetwork: network?.label || '',
|
|
207
|
-
cryptoAddress: cryptoAddress,
|
|
208
|
-
walletCode: walletCode?.bankCode || '',
|
|
110
|
+
bankCode: bank.bankCode,
|
|
209
111
|
branch: branch === 'BLANK' ? '' : branch, // 'BLANK'會置換成空值
|
|
210
|
-
branchCode,
|
|
211
112
|
bankAccount: accountNumber,
|
|
212
113
|
holderName,
|
|
213
|
-
pixType,
|
|
214
114
|
})
|
|
215
115
|
)
|
|
216
116
|
},
|
package/src/machine/common.js
CHANGED
|
@@ -29,19 +29,18 @@ export default function (request) {
|
|
|
29
29
|
},
|
|
30
30
|
paymentMethods: {},
|
|
31
31
|
},
|
|
32
|
-
layoutConfig: null,
|
|
33
32
|
userAgent: '',
|
|
34
33
|
isMobile: false,
|
|
35
34
|
announcementList: null,
|
|
36
35
|
broadcastList: null,
|
|
37
36
|
mailBoxInfo: null,
|
|
38
37
|
promotions: [],
|
|
38
|
+
emergencyBroadcast: null,
|
|
39
39
|
normalBroadcast: null,
|
|
40
|
+
sentEmergencyBroadcastList: [],
|
|
40
41
|
sentNormalBroadcastList: [],
|
|
41
42
|
channel: null,
|
|
42
43
|
subchannel: null,
|
|
43
|
-
affiliateCode: null,
|
|
44
|
-
friendCode: null,
|
|
45
44
|
},
|
|
46
45
|
states: {
|
|
47
46
|
config: {
|
|
@@ -55,12 +54,12 @@ export default function (request) {
|
|
|
55
54
|
},
|
|
56
55
|
},
|
|
57
56
|
fetching: {
|
|
58
|
-
entry: ['setUA', 'setAgent'
|
|
57
|
+
entry: ['setUA', 'setAgent'],
|
|
59
58
|
invoke: {
|
|
60
|
-
src: '
|
|
59
|
+
src: 'fetchSiteConfig',
|
|
61
60
|
onDone: {
|
|
62
61
|
target: 'idle',
|
|
63
|
-
actions: '
|
|
62
|
+
actions: 'setSiteConfig',
|
|
64
63
|
},
|
|
65
64
|
onError: {
|
|
66
65
|
target: 'idle',
|
|
@@ -93,30 +92,6 @@ export default function (request) {
|
|
|
93
92
|
},
|
|
94
93
|
},
|
|
95
94
|
},
|
|
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
|
-
},
|
|
120
95
|
broadcast: {
|
|
121
96
|
initial: 'idle',
|
|
122
97
|
states: {
|
|
@@ -159,28 +134,10 @@ export default function (request) {
|
|
|
159
134
|
},
|
|
160
135
|
},
|
|
161
136
|
actions: {
|
|
162
|
-
|
|
163
|
-
const {
|
|
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
|
-
}
|
|
137
|
+
setSiteConfig: assign((context, event) => {
|
|
138
|
+
const { loginMethods = {}, registerMethods = {} } = event.data
|
|
181
139
|
return {
|
|
182
|
-
siteConfig: { ...
|
|
183
|
-
layoutConfig: layoutConfigDecoded,
|
|
140
|
+
siteConfig: { ...event.data, loginMethods: pickBy(loginMethods), registerMethods: pickBy(registerMethods) },
|
|
184
141
|
}
|
|
185
142
|
}),
|
|
186
143
|
setUA: assign((context, event) => {
|
|
@@ -191,42 +148,14 @@ export default function (request) {
|
|
|
191
148
|
isMobile: userAgent?.device?.type,
|
|
192
149
|
}
|
|
193
150
|
}),
|
|
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
|
-
}),
|
|
220
151
|
setAgent: assign((context, event) => {
|
|
221
152
|
if (window.CC_JSB === true) {
|
|
222
153
|
// is cocos native app
|
|
223
|
-
return
|
|
154
|
+
return
|
|
224
155
|
} else {
|
|
225
156
|
let urlParams = new URLSearchParams(window.location.search)
|
|
226
157
|
const channel = urlParams.get('channel') || storage.get('channel') || defaultChannel || 'official'
|
|
227
158
|
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')
|
|
230
159
|
|
|
231
160
|
storage.set('channel', channel, {
|
|
232
161
|
path: '/',
|
|
@@ -236,75 +165,58 @@ export default function (request) {
|
|
|
236
165
|
path: '/',
|
|
237
166
|
maxAge: 60 * 60 * 24 * 7,
|
|
238
167
|
})
|
|
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
|
-
})
|
|
247
168
|
|
|
248
169
|
return {
|
|
249
170
|
channel,
|
|
250
171
|
subchannel,
|
|
251
|
-
affiliateCode,
|
|
252
|
-
friendCode,
|
|
253
172
|
}
|
|
254
173
|
}
|
|
255
174
|
}),
|
|
256
|
-
setAnnouncements: assign((context, event) => {
|
|
257
|
-
const { data } = event.data
|
|
258
|
-
return { announcementList: { data } }
|
|
259
|
-
}),
|
|
260
175
|
setFeeds: assign((context, event) => {
|
|
261
176
|
const { announcementList, broadcastList, mailBoxInfo } = event.data
|
|
262
177
|
const promotions = announcementList?.announcements?.filter?.((item) => item.category === 3) || []
|
|
263
|
-
return { broadcastList, mailBoxInfo, promotions }
|
|
178
|
+
return { announcementList, broadcastList, mailBoxInfo, promotions }
|
|
264
179
|
}),
|
|
265
180
|
setBroadcast: assign((context, event) => {
|
|
266
|
-
const { broadcastList, sentNormalBroadcastList, normalBroadcast } = context
|
|
181
|
+
const { broadcastList, sentEmergencyBroadcastList, emergencyBroadcast, sentNormalBroadcastList, normalBroadcast } = context
|
|
182
|
+
let sentEmergencyList = sentEmergencyBroadcastList
|
|
267
183
|
let sentNormalList = sentNormalBroadcastList
|
|
184
|
+
if (emergencyBroadcast) {
|
|
185
|
+
sentEmergencyList = [...sentEmergencyBroadcastList, emergencyBroadcast]
|
|
186
|
+
}
|
|
268
187
|
if (normalBroadcast) {
|
|
269
188
|
sentNormalList = [...sentNormalBroadcastList, normalBroadcast]
|
|
270
189
|
}
|
|
190
|
+
const nextEmergencyBroadcast = broadcastList?.broadcasts?.find((broadcast) => {
|
|
191
|
+
return broadcast.type === '1' && !sentEmergencyList.some((item) => item.broadcast_id === broadcast.broadcast_id)
|
|
192
|
+
})
|
|
271
193
|
const nextNormalBroadcast = broadcastList?.broadcasts?.find((broadcast) => {
|
|
272
194
|
return broadcast.type === '0' && !sentNormalList.some((item) => item.broadcast_id === broadcast.broadcast_id)
|
|
273
195
|
})
|
|
274
196
|
return {
|
|
197
|
+
emergencyBroadcast: nextEmergencyBroadcast,
|
|
198
|
+
sentEmergencyBroadcastList: sentEmergencyList,
|
|
275
199
|
normalBroadcast: nextNormalBroadcast,
|
|
276
200
|
sentNormalBroadcastList: sentNormalList,
|
|
277
201
|
}
|
|
278
202
|
}),
|
|
279
203
|
resetBroadcast: assign((context, event) => {
|
|
280
204
|
return {
|
|
205
|
+
emergencyBroadcast: null,
|
|
206
|
+
sentEmergencyBroadcastList: [],
|
|
281
207
|
normalBroadcast: null,
|
|
282
208
|
sentNormalBroadcastList: [],
|
|
283
209
|
}
|
|
284
210
|
}),
|
|
285
211
|
},
|
|
286
212
|
services: {
|
|
287
|
-
|
|
288
|
-
const
|
|
289
|
-
|
|
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 }
|
|
213
|
+
fetchSiteConfig: async (context, event) => {
|
|
214
|
+
const { config } = await request.send(api.getConfig({ appSecret }))
|
|
215
|
+
return JSON.parse(window.atob(config))
|
|
301
216
|
},
|
|
302
217
|
fetchFeeds: async (context, event) => {
|
|
303
218
|
return await request.send(api.feeds({ appSecret }))
|
|
304
219
|
},
|
|
305
|
-
fetchAnnouncements: async (context, event) => {
|
|
306
|
-
return await request.send(api.getAnnouncements({ appSecret }))
|
|
307
|
-
},
|
|
308
220
|
},
|
|
309
221
|
}
|
|
310
222
|
)
|
|
@@ -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: [],
|
|
@@ -19,7 +18,6 @@ export default function (request) {
|
|
|
19
18
|
sourceAddress: '',
|
|
20
19
|
|
|
21
20
|
amount: null,
|
|
22
|
-
selectedChannel: null,
|
|
23
21
|
selectedCrypto: null,
|
|
24
22
|
selectedNetwork: null,
|
|
25
23
|
|
|
@@ -28,24 +26,21 @@ export default function (request) {
|
|
|
28
26
|
|
|
29
27
|
calculation: null,
|
|
30
28
|
result: null,
|
|
31
|
-
|
|
32
|
-
// use for wallet mode 4
|
|
33
|
-
promotion: null,
|
|
34
29
|
},
|
|
35
30
|
states: {
|
|
36
31
|
loading: {
|
|
37
32
|
invoke: {
|
|
38
|
-
src: '
|
|
33
|
+
src: 'fetchPayments',
|
|
39
34
|
onDone: {
|
|
40
|
-
target: '
|
|
41
|
-
actions: '
|
|
35
|
+
target: 'idle',
|
|
36
|
+
actions: 'setCryptos',
|
|
42
37
|
},
|
|
43
38
|
onError: {
|
|
44
39
|
target: '#crypto.fail',
|
|
45
40
|
},
|
|
46
41
|
},
|
|
47
42
|
},
|
|
48
|
-
|
|
43
|
+
idle: {
|
|
49
44
|
always: [{ target: 'debouncing', cond: 'isCalculable' }],
|
|
50
45
|
},
|
|
51
46
|
debouncing: {
|
|
@@ -55,6 +50,13 @@ export default function (request) {
|
|
|
55
50
|
},
|
|
56
51
|
},
|
|
57
52
|
},
|
|
53
|
+
// calculable: {
|
|
54
|
+
// on: {
|
|
55
|
+
// CALCULATE: {
|
|
56
|
+
// target: 'calculating',
|
|
57
|
+
// },
|
|
58
|
+
// },
|
|
59
|
+
// },
|
|
58
60
|
calculating: {
|
|
59
61
|
invoke: {
|
|
60
62
|
src: 'fetchCalculation',
|
|
@@ -63,25 +65,11 @@ export default function (request) {
|
|
|
63
65
|
actions: 'setCalculation',
|
|
64
66
|
},
|
|
65
67
|
onError: {
|
|
66
|
-
target: '
|
|
68
|
+
target: 'idle',
|
|
67
69
|
},
|
|
68
70
|
},
|
|
69
71
|
},
|
|
70
72
|
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
73
|
on: {
|
|
86
74
|
SUBMIT: {
|
|
87
75
|
target: 'submitting',
|
|
@@ -97,7 +85,7 @@ export default function (request) {
|
|
|
97
85
|
actions: 'setResult',
|
|
98
86
|
},
|
|
99
87
|
onError: {
|
|
100
|
-
target: '
|
|
88
|
+
target: 'idle',
|
|
101
89
|
},
|
|
102
90
|
},
|
|
103
91
|
},
|
|
@@ -106,24 +94,28 @@ export default function (request) {
|
|
|
106
94
|
},
|
|
107
95
|
on: {
|
|
108
96
|
SET_CHANNEL: {
|
|
109
|
-
target: '.
|
|
97
|
+
target: '.idle',
|
|
110
98
|
actions: 'setChannel',
|
|
111
99
|
},
|
|
112
100
|
SET_CRYPTO: {
|
|
113
|
-
target: '.
|
|
101
|
+
target: '.idle',
|
|
114
102
|
actions: 'setCrypto',
|
|
115
103
|
},
|
|
116
104
|
SET_NETWORK: {
|
|
117
|
-
target: '.
|
|
105
|
+
target: '.idle',
|
|
118
106
|
actions: 'setNetwork',
|
|
119
107
|
},
|
|
120
108
|
SET_ADDRESS: {
|
|
121
109
|
actions: 'setAddress',
|
|
122
110
|
},
|
|
123
111
|
SET_AMOUNT: {
|
|
124
|
-
target: '.
|
|
112
|
+
target: '.idle',
|
|
125
113
|
actions: ['setAmount', 'clearCalculation'],
|
|
126
114
|
},
|
|
115
|
+
// CLEAR_CALCULATION: {
|
|
116
|
+
// target: '.idle',
|
|
117
|
+
// actions: 'clearCalculation',
|
|
118
|
+
// },
|
|
127
119
|
CALCULATE: {
|
|
128
120
|
target: '.debouncing',
|
|
129
121
|
actions: 'clearCalculation',
|
|
@@ -132,13 +124,9 @@ export default function (request) {
|
|
|
132
124
|
},
|
|
133
125
|
{
|
|
134
126
|
actions: {
|
|
135
|
-
|
|
136
|
-
const {
|
|
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]
|
|
127
|
+
setCryptos: assign((context, event) => {
|
|
128
|
+
const cryptos = event.data?.map?.((crypto) => ({ ...crypto, label: crypto.channel, value: crypto.method, icon: crypto.channel })) || []
|
|
129
|
+
const currentPayment = cryptos.find((element) => element.category === context.currentCategory)
|
|
142
130
|
const channels = cryptos.map((item, i) => ({ ...item, label: `Channel ${padStart(String(i + 1), 2, '0')}`, icon: 'channel' }))
|
|
143
131
|
const defaultNetworks =
|
|
144
132
|
cryptos[0].networkName.map((value, i) => {
|
|
@@ -149,7 +137,6 @@ export default function (request) {
|
|
|
149
137
|
}
|
|
150
138
|
}) || []
|
|
151
139
|
return {
|
|
152
|
-
siteConfig,
|
|
153
140
|
channels,
|
|
154
141
|
cryptos,
|
|
155
142
|
networks: defaultNetworks,
|
|
@@ -234,9 +221,6 @@ export default function (request) {
|
|
|
234
221
|
}),
|
|
235
222
|
},
|
|
236
223
|
guards: {
|
|
237
|
-
isDoubleWalletMode: (context, event) => {
|
|
238
|
-
return context.siteConfig?.walletMode === '4'
|
|
239
|
-
},
|
|
240
224
|
isCalculable: (context, event) => {
|
|
241
225
|
const {
|
|
242
226
|
selectedCrypto,
|
|
@@ -252,13 +236,8 @@ export default function (request) {
|
|
|
252
236
|
},
|
|
253
237
|
},
|
|
254
238
|
services: {
|
|
255
|
-
|
|
256
|
-
|
|
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 }
|
|
239
|
+
fetchPayments: async (context, event) => {
|
|
240
|
+
return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
|
|
262
241
|
},
|
|
263
242
|
fetchCalculation: async (context, event) => {
|
|
264
243
|
const { selectedCrypto, amount } = context
|
|
@@ -273,7 +252,7 @@ export default function (request) {
|
|
|
273
252
|
submitDeposit: async (context, event) => {
|
|
274
253
|
const { selectedCrypto, selectedNetwork, calculation, sourceAddress } = context
|
|
275
254
|
return await request.send(
|
|
276
|
-
payment.
|
|
255
|
+
payment.submitDepositTransaction({
|
|
277
256
|
method: selectedCrypto.method,
|
|
278
257
|
amount: calculation.actualAmount,
|
|
279
258
|
cryptoCurrency: selectedCrypto.channel,
|