@jetthai/cuora 1.0.307-dev-2 → 1.1.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 +4 -853
- 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 +25 -141
- 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 +30 -110
- 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 +21 -112
- 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,19 @@ 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
|
-
|
|
44
|
-
friendCode: null,
|
|
44
|
+
referralCode: null
|
|
45
45
|
},
|
|
46
46
|
states: {
|
|
47
47
|
config: {
|
|
@@ -55,12 +55,12 @@ export default function (request) {
|
|
|
55
55
|
},
|
|
56
56
|
},
|
|
57
57
|
fetching: {
|
|
58
|
-
entry: ['setUA', 'setAgent'
|
|
58
|
+
entry: ['setUA', 'setAgent'],
|
|
59
59
|
invoke: {
|
|
60
|
-
src: '
|
|
60
|
+
src: 'fetchSiteConfig',
|
|
61
61
|
onDone: {
|
|
62
62
|
target: 'idle',
|
|
63
|
-
actions: '
|
|
63
|
+
actions: 'setSiteConfig',
|
|
64
64
|
},
|
|
65
65
|
onError: {
|
|
66
66
|
target: 'idle',
|
|
@@ -93,30 +93,6 @@ export default function (request) {
|
|
|
93
93
|
},
|
|
94
94
|
},
|
|
95
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
|
-
},
|
|
120
96
|
broadcast: {
|
|
121
97
|
initial: 'idle',
|
|
122
98
|
states: {
|
|
@@ -159,28 +135,10 @@ export default function (request) {
|
|
|
159
135
|
},
|
|
160
136
|
},
|
|
161
137
|
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
|
-
}
|
|
138
|
+
setSiteConfig: assign((context, event) => {
|
|
139
|
+
const { loginMethods = {}, registerMethods = {} } = event.data
|
|
181
140
|
return {
|
|
182
|
-
siteConfig: { ...
|
|
183
|
-
layoutConfig: layoutConfigDecoded,
|
|
141
|
+
siteConfig: { ...event.data, loginMethods: pickBy(loginMethods), registerMethods: pickBy(registerMethods) },
|
|
184
142
|
}
|
|
185
143
|
}),
|
|
186
144
|
setUA: assign((context, event) => {
|
|
@@ -191,42 +149,15 @@ export default function (request) {
|
|
|
191
149
|
isMobile: userAgent?.device?.type,
|
|
192
150
|
}
|
|
193
151
|
}),
|
|
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
152
|
setAgent: assign((context, event) => {
|
|
221
153
|
if (window.CC_JSB === true) {
|
|
222
154
|
// is cocos native app
|
|
223
|
-
return
|
|
155
|
+
return
|
|
224
156
|
} else {
|
|
225
157
|
let urlParams = new URLSearchParams(window.location.search)
|
|
226
158
|
const channel = urlParams.get('channel') || storage.get('channel') || defaultChannel || 'official'
|
|
227
159
|
const subchannel = urlParams.get('subchannel') || storage.get('subchannel') || defaultSubchannel || 'pwa'
|
|
228
|
-
const
|
|
229
|
-
const friendCode = urlParams.get('fc') || urlParams.get('affiliate') || storage.get('fc') || storage.get('affiliate')
|
|
160
|
+
const referralCode = urlParams.get('referralCode') || storage.get('referralCode')
|
|
230
161
|
|
|
231
162
|
storage.set('channel', channel, {
|
|
232
163
|
path: '/',
|
|
@@ -236,75 +167,64 @@ export default function (request) {
|
|
|
236
167
|
path: '/',
|
|
237
168
|
maxAge: 60 * 60 * 24 * 7,
|
|
238
169
|
})
|
|
239
|
-
storage.set('
|
|
240
|
-
path: '/',
|
|
241
|
-
maxAge: 60 * 60 * 24 * 7,
|
|
242
|
-
})
|
|
243
|
-
storage.set('fc', friendCode, {
|
|
170
|
+
storage.set('referralCode', referralCode, {
|
|
244
171
|
path: '/',
|
|
245
172
|
maxAge: 60 * 60 * 24 * 7,
|
|
246
173
|
})
|
|
247
174
|
|
|
175
|
+
|
|
248
176
|
return {
|
|
249
177
|
channel,
|
|
250
178
|
subchannel,
|
|
251
|
-
|
|
252
|
-
friendCode,
|
|
179
|
+
referralCode
|
|
253
180
|
}
|
|
254
181
|
}
|
|
255
182
|
}),
|
|
256
|
-
setAnnouncements: assign((context, event) => {
|
|
257
|
-
const { data } = event.data
|
|
258
|
-
return { announcementList: { data } }
|
|
259
|
-
}),
|
|
260
183
|
setFeeds: assign((context, event) => {
|
|
261
184
|
const { announcementList, broadcastList, mailBoxInfo } = event.data
|
|
262
185
|
const promotions = announcementList?.announcements?.filter?.((item) => item.category === 3) || []
|
|
263
|
-
return { broadcastList, mailBoxInfo, promotions }
|
|
186
|
+
return { announcementList, broadcastList, mailBoxInfo, promotions }
|
|
264
187
|
}),
|
|
265
188
|
setBroadcast: assign((context, event) => {
|
|
266
|
-
const { broadcastList, sentNormalBroadcastList, normalBroadcast } = context
|
|
189
|
+
const { broadcastList, sentEmergencyBroadcastList, emergencyBroadcast, sentNormalBroadcastList, normalBroadcast } = context
|
|
190
|
+
let sentEmergencyList = sentEmergencyBroadcastList
|
|
267
191
|
let sentNormalList = sentNormalBroadcastList
|
|
192
|
+
if (emergencyBroadcast) {
|
|
193
|
+
sentEmergencyList = [...sentEmergencyBroadcastList, emergencyBroadcast]
|
|
194
|
+
}
|
|
268
195
|
if (normalBroadcast) {
|
|
269
196
|
sentNormalList = [...sentNormalBroadcastList, normalBroadcast]
|
|
270
197
|
}
|
|
198
|
+
const nextEmergencyBroadcast = broadcastList?.broadcasts?.find((broadcast) => {
|
|
199
|
+
return broadcast.type === '1' && !sentEmergencyList.some((item) => item.broadcast_id === broadcast.broadcast_id)
|
|
200
|
+
})
|
|
271
201
|
const nextNormalBroadcast = broadcastList?.broadcasts?.find((broadcast) => {
|
|
272
202
|
return broadcast.type === '0' && !sentNormalList.some((item) => item.broadcast_id === broadcast.broadcast_id)
|
|
273
203
|
})
|
|
274
204
|
return {
|
|
205
|
+
emergencyBroadcast: nextEmergencyBroadcast,
|
|
206
|
+
sentEmergencyBroadcastList: sentEmergencyList,
|
|
275
207
|
normalBroadcast: nextNormalBroadcast,
|
|
276
208
|
sentNormalBroadcastList: sentNormalList,
|
|
277
209
|
}
|
|
278
210
|
}),
|
|
279
211
|
resetBroadcast: assign((context, event) => {
|
|
280
212
|
return {
|
|
213
|
+
emergencyBroadcast: null,
|
|
214
|
+
sentEmergencyBroadcastList: [],
|
|
281
215
|
normalBroadcast: null,
|
|
282
216
|
sentNormalBroadcastList: [],
|
|
283
217
|
}
|
|
284
218
|
}),
|
|
285
219
|
},
|
|
286
220
|
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 }
|
|
221
|
+
fetchSiteConfig: async (context, event) => {
|
|
222
|
+
const { config } = await request.send(api.getConfig({ appSecret }))
|
|
223
|
+
return JSON.parse(window.atob(config))
|
|
301
224
|
},
|
|
302
225
|
fetchFeeds: async (context, event) => {
|
|
303
226
|
return await request.send(api.feeds({ appSecret }))
|
|
304
227
|
},
|
|
305
|
-
fetchAnnouncements: async (context, event) => {
|
|
306
|
-
return await request.send(api.getAnnouncements({ appSecret }))
|
|
307
|
-
},
|
|
308
228
|
},
|
|
309
229
|
}
|
|
310
230
|
)
|
|
@@ -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,
|