@jetthai/cuora 1.2.0 → 2.0.0-beta.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/BREAKING_CHANGES.md +9 -0
- package/CHANGELOG.md +36 -0
- package/package.json +5 -2
- package/resetGitBranch.sh +16 -16
- package/src/api/account.js +8 -0
- package/src/api/auth.js +1 -1
- package/src/api/common.js +6 -1
- package/src/api/index.js +3 -1
- package/src/api/otp.js +5 -0
- package/src/api/user.js +1 -0
- package/src/machine/activity/activity.js +23 -19
- package/src/machine/activity/activity_cash.js +27 -22
- package/src/machine/activity/cash_rain_activity.js +1 -0
- package/src/machine/activity/continue_deposit_activity.js +1 -0
- package/src/machine/activity/deposit_activity.js +1 -0
- package/src/machine/activity/diamond_shop_activity_cash.js +7 -0
- package/src/machine/activity/diamond_shop_activity_fc.js +1 -0
- package/src/machine/activity/diamond_shop_activity_vn.js +1 -0
- package/src/machine/activity/fafafa_activity.js +1 -0
- package/src/machine/activity/friend_invite_friends_activity.js +7 -8
- package/src/machine/activity/instant_rebate_activity.js +1 -0
- package/src/machine/activity/invite_friends_activity.js +1 -0
- package/src/machine/activity/jackpot.js +1 -0
- package/src/machine/activity/mini_game_activity.js +1 -0
- package/src/machine/activity/otp_verified_activity.js +1 -0
- package/src/machine/activity/ranking_activity.js +1 -0
- package/src/machine/activity/return_bonus_activity.js +3 -1
- package/src/machine/activity/roulette_activity_v2.js +6 -0
- package/src/machine/activity/sign_in_activity.js +1 -0
- package/src/machine/activity/sign_in_monthly_activity.js +2 -1
- package/src/machine/activity/specify_bets_activity.js +1 -0
- package/src/machine/activity/specify_turnover_activity.js +1 -0
- package/src/machine/activity/time_bomb_activity.js +1 -0
- package/src/machine/activity/vip_card_activity.js +1 -0
- package/src/machine/auth.js +21 -8
- package/src/machine/auth_otp_v2.js +1 -0
- package/src/machine/auth_otp_v3.js +48 -11
- package/src/machine/bank_binding.js +1 -0
- package/src/machine/bank_binding_amb.js +1 -0
- package/src/machine/bonus.js +1 -0
- package/src/machine/common.js +41 -7
- package/src/machine/deposit/amb.js +1 -0
- package/src/machine/deposit/crypto_bank.js +20 -5
- package/src/machine/deposit/crypto_bank_cash.js +35 -9
- package/src/machine/deposit/crypto_qrcode.js +11 -1
- package/src/machine/deposit/crypto_qrcode_cash.js +24 -1
- package/src/machine/deposit/crypto_way.js +11 -5
- package/src/machine/deposit/crypto_way_cash.js +15 -6
- package/src/machine/deposit/deposit_fc.js +1 -0
- package/src/machine/deposit/direct.js +1 -0
- package/src/machine/deposit/direct_cash.js +1 -0
- package/src/machine/deposit/float.js +1 -0
- package/src/machine/deposit/krway.js +1 -0
- package/src/machine/deposit/loadcard_cash.js +2 -1
- package/src/machine/deposit/loadcard_vn.js +1 -0
- package/src/machine/deposit/manual_cash.js +18 -10
- package/src/machine/deposit/manual_vn.js +10 -5
- package/src/machine/deposit/qrcode_cash.js +6 -5
- package/src/machine/deposit/qrcode_v2.js +1 -0
- package/src/machine/deposit/usdt.js +23 -4
- package/src/machine/deposit/usdt_cash.js +15 -1
- package/src/machine/deposit/virtual_bank_cash.js +11 -9
- package/src/machine/deposit/virtual_bank_vn.js +1 -0
- package/src/machine/deposit/vpay.js +7 -0
- package/src/machine/error.js +1 -0
- package/src/machine/game_betslip.js +1 -0
- package/src/machine/game_favorite_v2.js +1 -0
- package/src/machine/game_hot_new.js +14 -2
- package/src/machine/game_info.js +5 -0
- package/src/machine/game_replay.js +1 -0
- package/src/machine/game_search_cash.js +13 -2
- package/src/machine/game_search_v2.js +1 -0
- package/src/machine/game_v2_1.js +129 -50
- package/src/machine/honor_board.js +19 -7
- package/src/machine/honor_board_cash.js +11 -8
- package/src/machine/inbox.js +93 -43
- package/src/machine/leaderboard.js +1 -0
- package/src/machine/merge.js +1 -0
- package/src/machine/navbar.js +3 -1
- package/src/machine/payment_data.js +1 -0
- package/src/machine/promotions.js +11 -18
- package/src/machine/ranking.js +5 -2
- package/src/machine/reward.js +1 -0
- package/src/machine/reward_cash.js +1 -0
- package/src/machine/reward_fc.js +1 -0
- package/src/machine/roulette_v2.js +18 -26
- package/src/machine/setting.js +1 -0
- package/src/machine/side.js +10 -4
- package/src/machine/side_cash.js +1 -0
- package/src/machine/side_v2.js +38 -24
- package/src/machine/user_info.js +1 -0
- package/src/machine/user_photo.js +1 -0
- package/src/machine/user_reset_password.js +5 -2
- package/src/machine/user_sign_up.js +1 -0
- package/src/machine/vip_table.js +1 -0
- package/src/machine/websocket.js +42 -14
- package/src/machine/welcome.js +1 -0
- package/src/machine/withdraw/withdraw_crypto_cash.js +1 -0
- package/src/machine/withdraw/withdraw_krway.js +1 -0
- package/src/machine/withdraw/withdraw_manual.js +16 -8
- package/src/machine/withdraw/withdraw_manual_cash.js +1 -0
- package/src/request/request.js +34 -30
- package/src/util/deviceToken.js +7 -6
- package/src/util/storage.js +4 -3
- package/test/api.behavior.test.js +69 -0
- package/test/api.contract.test.js +18 -0
- package/test/config.test.js +27 -0
- package/test/deviceToken.test.js +139 -0
- package/test/helpers.coverage.test.js +11 -0
- package/test/helpers.js +91 -0
- package/test/index.exports.test.js +14 -0
- package/test/machine.activity.core.coverage.test.js +337 -0
- package/test/machine.activity.gap.coverage.test.js +252 -0
- package/test/machine.activity.more.coverage.test.js +180 -0
- package/test/machine.activity_plus_and_binding_amb.coverage.test.js +201 -0
- package/test/machine.activity_timer_bonus.coverage.test.js +136 -0
- package/test/machine.activity_welcome.low.coverage.test.js +211 -0
- package/test/machine.amb_rewardfc_websocket.more.coverage.test.js +201 -0
- package/test/machine.auth.coverage.test.js +215 -0
- package/test/machine.bank_binding.test.js +143 -0
- package/test/machine.binding_otp_krway.coverage.test.js +223 -0
- package/test/machine.contract.test.js +50 -0
- package/test/machine.crypto_bank.coverage.test.js +270 -0
- package/test/machine.crypto_way.coverage.test.js +108 -0
- package/test/machine.crypto_way_cash.coverage.test.js +114 -0
- package/test/machine.definition.test.js +137 -0
- package/test/machine.deposit.manual.coverage.test.js +365 -0
- package/test/machine.deposit_fc.coverage.test.js +126 -0
- package/test/machine.direct.coverage.test.js +96 -0
- package/test/machine.direct_cash.coverage.test.js +108 -0
- package/test/machine.error.coverage.test.js +37 -0
- package/test/machine.events.test.js +126 -0
- package/test/machine.favorite_jackpot.coverage.test.js +82 -0
- package/test/machine.float.coverage.test.js +136 -0
- package/test/machine.flow.test.js +226 -0
- package/test/machine.game_hot_new_vip_table.coverage.test.js +105 -0
- package/test/machine.game_search_cash.coverage.test.js +195 -0
- package/test/machine.game_search_v2.test.js +199 -0
- package/test/machine.game_user_profile.coverage.test.js +100 -0
- package/test/machine.honor_board.test.js +148 -0
- package/test/machine.inbox.common.coverage.test.js +304 -0
- package/test/machine.loadcard_cash.coverage.test.js +101 -0
- package/test/machine.loadcard_vn.coverage.test.js +122 -0
- package/test/machine.misc.coverage.test.js +361 -0
- package/test/machine.more2.coverage.test.js +261 -0
- package/test/machine.options.execution.test.js +272 -0
- package/test/machine.priority.coverage.test.js +629 -0
- package/test/machine.qrcode_cash.coverage.test.js +107 -0
- package/test/machine.qrcode_v2.coverage.test.js +121 -0
- package/test/machine.regression.test.js +82 -0
- package/test/machine.roulette_v2.test.js +142 -0
- package/test/machine.side_reward_reset.coverage.test.js +220 -0
- package/test/machine.targeted.coverage.test.js +313 -0
- package/test/machine.usdt.coverage.test.js +95 -0
- package/test/machine.usdt_cash.coverage.test.js +73 -0
- package/test/machine.vip_card_activity.test.js +114 -0
- package/test/machine.virtual_bank_cash.coverage.test.js +105 -0
- package/test/machine.virtual_bank_vn.coverage.test.js +105 -0
- package/test/machine.vpay.coverage.test.js +142 -0
- package/test/machine.withdraw_crypto_cash.coverage.test.js +166 -0
- package/test/machine.withdraw_krway.coverage.test.js +123 -0
- package/test/machine.withdraw_manual.coverage.test.js +185 -0
- package/test/machine.withdraw_manual_cash.coverage.test.js +123 -0
- package/test/request.test.js +325 -0
- package/test/util.storage.errors.test.js +47 -0
- package/test/util.test.js +41 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { assign, createMachine } from 'xstate'
|
|
2
|
-
import payment from '
|
|
2
|
+
import payment from '../../api/payment.js'
|
|
3
3
|
import { max } from '../../util/index.js'
|
|
4
4
|
|
|
5
5
|
export default function (request, context) {
|
|
@@ -7,6 +7,7 @@ export default function (request, context) {
|
|
|
7
7
|
return createMachine(
|
|
8
8
|
{
|
|
9
9
|
id: 'crypto_way_cash',
|
|
10
|
+
predictableActionArguments: true,
|
|
10
11
|
initial: 'loading',
|
|
11
12
|
context: {
|
|
12
13
|
paymentDetail,
|
|
@@ -79,10 +80,15 @@ export default function (request, context) {
|
|
|
79
80
|
actions: ['setResult', 'setTtl'],
|
|
80
81
|
},
|
|
81
82
|
onError: {
|
|
82
|
-
target: '
|
|
83
|
+
target: 'fail',
|
|
83
84
|
},
|
|
84
85
|
},
|
|
85
86
|
},
|
|
87
|
+
fail: {
|
|
88
|
+
after: {
|
|
89
|
+
0: { target: 'calculated' },
|
|
90
|
+
},
|
|
91
|
+
},
|
|
86
92
|
submitted: {
|
|
87
93
|
after: {
|
|
88
94
|
1000: {
|
|
@@ -136,17 +142,20 @@ export default function (request, context) {
|
|
|
136
142
|
return {
|
|
137
143
|
cryptos,
|
|
138
144
|
selectedCrypto: cryptos[0],
|
|
139
|
-
options: cryptos[0]
|
|
145
|
+
options: cryptos[0]?.optional || [],
|
|
140
146
|
}
|
|
141
147
|
}),
|
|
142
148
|
setCrypto: assign((context, event) => {
|
|
143
149
|
const { cryptos } = context
|
|
144
150
|
const selectedCrypto = cryptos.find((crypto) => crypto.label === event.data.label)
|
|
151
|
+
if (!selectedCrypto) {
|
|
152
|
+
return {}
|
|
153
|
+
}
|
|
145
154
|
return {
|
|
146
155
|
selectedCrypto: selectedCrypto,
|
|
147
156
|
selectedAmount: null,
|
|
148
157
|
calculation: null,
|
|
149
|
-
options: selectedCrypto.optional,
|
|
158
|
+
options: selectedCrypto.optional || [],
|
|
150
159
|
}
|
|
151
160
|
}),
|
|
152
161
|
setAmount: assign((context, event) => {
|
|
@@ -192,10 +201,10 @@ export default function (request, context) {
|
|
|
192
201
|
}),
|
|
193
202
|
setPromotion: assign((context, event) => {
|
|
194
203
|
const { selectedCrypto, selectedAmount } = context
|
|
195
|
-
const promotion = event.data
|
|
204
|
+
const promotion = event.data || {}
|
|
196
205
|
return {
|
|
197
206
|
promotion,
|
|
198
|
-
selectedAmount: max(promotion
|
|
207
|
+
selectedAmount: max(promotion?.minimumAmount, selectedCrypto?.minimum, selectedAmount, 0),
|
|
199
208
|
calculation: null,
|
|
200
209
|
}
|
|
201
210
|
}),
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { assign, createMachine } from 'xstate'
|
|
2
2
|
import payment from '../../api/payment.js'
|
|
3
|
-
import { max } from '../../util'
|
|
3
|
+
import { max } from '../../util/index.js'
|
|
4
4
|
|
|
5
5
|
export default function (request, context) {
|
|
6
6
|
const { paymentDetail = [], promotion, selectedAmount } = context || {}
|
|
7
7
|
return createMachine(
|
|
8
8
|
{
|
|
9
9
|
id: 'qrcode_cash',
|
|
10
|
+
predictableActionArguments: true,
|
|
10
11
|
initial: 'loading',
|
|
11
12
|
context: {
|
|
12
13
|
currentCategory: 'loadcard',
|
|
@@ -9,6 +9,7 @@ export default function (request, context) {
|
|
|
9
9
|
return createMachine(
|
|
10
10
|
{
|
|
11
11
|
id: 'manual_cash',
|
|
12
|
+
predictableActionArguments: true,
|
|
12
13
|
initial: 'loading',
|
|
13
14
|
context: {
|
|
14
15
|
siteConfig,
|
|
@@ -151,25 +152,32 @@ export default function (request, context) {
|
|
|
151
152
|
const { currentPayment, bankList, bindingPaymentInfo, processing } = event.data
|
|
152
153
|
const userBankLsit = bindingPaymentInfo.bankList || []
|
|
153
154
|
const allBankList = bankList?.data ? bankList.data : bankList
|
|
155
|
+
const bankMetaMap = new Map((allBankList || []).map((item) => [item.bankCode, item]))
|
|
154
156
|
|
|
155
157
|
const houseBanks = currentPayment.banks.map((bank) => {
|
|
156
|
-
const foundBank =
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
158
|
+
const foundBank = bankMetaMap.get(bank.bankName)
|
|
159
|
+
return {
|
|
160
|
+
...bank,
|
|
161
|
+
...foundBank,
|
|
162
|
+
bankCode: bank.bankName, // because api has no bankCode field
|
|
163
|
+
displayText: foundBank?.shortName,
|
|
164
|
+
imageUrl: foundBank?.imageUrl,
|
|
165
|
+
}
|
|
161
166
|
})
|
|
162
167
|
|
|
163
168
|
const formattedUserBanks = userBankLsit.map((bank) => {
|
|
164
|
-
const foundBank =
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
169
|
+
const foundBank = bankMetaMap.get(bank.bankCode)
|
|
170
|
+
return {
|
|
171
|
+
...bank,
|
|
172
|
+
...foundBank,
|
|
173
|
+
displayText: `${foundBank?.shortName} ${bank.accountNumber.slice(-5)}`,
|
|
174
|
+
imageUrl: foundBank?.imageUrl,
|
|
175
|
+
}
|
|
168
176
|
})
|
|
169
177
|
|
|
170
178
|
const userBanks = [
|
|
171
179
|
...formattedUserBanks,
|
|
172
|
-
...allBankList.map((bank) => ({
|
|
180
|
+
...(allBankList || []).map((bank) => ({
|
|
173
181
|
...bank,
|
|
174
182
|
displayText: bank.shortName,
|
|
175
183
|
})),
|
|
@@ -7,6 +7,7 @@ export default function (request) {
|
|
|
7
7
|
return createMachine(
|
|
8
8
|
{
|
|
9
9
|
id: 'manual',
|
|
10
|
+
predictableActionArguments: true,
|
|
10
11
|
initial: 'loading',
|
|
11
12
|
context: {
|
|
12
13
|
siteConfig: null,
|
|
@@ -253,20 +254,24 @@ export default function (request) {
|
|
|
253
254
|
const { bindingPaymentInfo = {}, bindingPaymentList = {} } = event.data || {}
|
|
254
255
|
const userBankLsit = bindingPaymentInfo.bankList || []
|
|
255
256
|
const allBankList = bindingPaymentList.bankList || []
|
|
257
|
+
const bankMetaMap = new Map(allBankList.map((item) => [item.bankCode, item]))
|
|
256
258
|
const { currentPayment, houseBanks, selectedHouseBank } = context
|
|
257
259
|
const { banks = [] } = currentPayment
|
|
258
260
|
|
|
259
261
|
const formettedPlayerBanks = userBankLsit.map((bank) => {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
262
|
+
const matchedBank = bankMetaMap.get(bank.bankCode)
|
|
263
|
+
return {
|
|
264
|
+
...bank,
|
|
265
|
+
shortName: `${bank.bankCode} ${bank.accountNumber.slice(-5)}`,
|
|
266
|
+
imageUrl: matchedBank?.imageUrl,
|
|
267
|
+
}
|
|
263
268
|
})
|
|
264
269
|
const playerBanks = [...formettedPlayerBanks, ...allBankList]
|
|
265
270
|
|
|
266
271
|
const newHouseBanks = houseBanks.map((houseBank) => {
|
|
267
|
-
return { ...houseBank, ...
|
|
272
|
+
return { ...houseBank, ...bankMetaMap.get(houseBank.bankName) }
|
|
268
273
|
})
|
|
269
|
-
const newSelectedHouseBank = { ...selectedHouseBank, ...
|
|
274
|
+
const newSelectedHouseBank = { ...selectedHouseBank, ...bankMetaMap.get(selectedHouseBank.bankName) }
|
|
270
275
|
|
|
271
276
|
return {
|
|
272
277
|
playerBanks,
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { assign, createMachine } from 'xstate'
|
|
2
2
|
import payment from '../../api/payment.js'
|
|
3
|
-
import { max } from '../../util'
|
|
3
|
+
import { max } from '../../util/index.js'
|
|
4
4
|
|
|
5
5
|
export default function (request, context) {
|
|
6
6
|
const { paymentDetail = [], promotion, selectedAmount } = context || {}
|
|
7
7
|
return createMachine(
|
|
8
8
|
{
|
|
9
9
|
id: 'qrcode_cash',
|
|
10
|
+
predictableActionArguments: true,
|
|
10
11
|
initial: 'loading',
|
|
11
12
|
context: {
|
|
12
13
|
paymentDetail,
|
|
@@ -136,15 +137,15 @@ export default function (request, context) {
|
|
|
136
137
|
}),
|
|
137
138
|
setPromotion: assign((context, event) => {
|
|
138
139
|
const { selectedAmount } = context
|
|
139
|
-
const promotion = event.data
|
|
140
|
-
const qrcodes = context.qrcodes
|
|
140
|
+
const promotion = event.data || {}
|
|
141
|
+
const qrcodes = Array.isArray(context.qrcodes) ? context.qrcodes : []
|
|
141
142
|
const selectedQrcode = qrcodes[0]
|
|
142
143
|
return {
|
|
143
144
|
promotion,
|
|
144
145
|
qrcodes,
|
|
145
146
|
selectedQrcode,
|
|
146
147
|
options: selectedQrcode?.optional,
|
|
147
|
-
selectedAmount: max(promotion
|
|
148
|
+
selectedAmount: max(promotion?.minimumAmount, selectedQrcode?.minimum, selectedAmount, 0),
|
|
148
149
|
calculation: null,
|
|
149
150
|
}
|
|
150
151
|
}),
|
|
@@ -195,7 +196,7 @@ export default function (request, context) {
|
|
|
195
196
|
},
|
|
196
197
|
guards: {
|
|
197
198
|
hasQrcodeMethods: (context, event) => {
|
|
198
|
-
return context.paymentDetail?.
|
|
199
|
+
return context.paymentDetail?.some((element) => element.category === context.currentCategory) || false
|
|
199
200
|
},
|
|
200
201
|
},
|
|
201
202
|
services: {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { assign, createMachine } from 'xstate'
|
|
2
|
-
import payment from '
|
|
2
|
+
import payment from '../../api/payment.js'
|
|
3
3
|
|
|
4
4
|
export default function (request) {
|
|
5
5
|
return createMachine(
|
|
6
6
|
{
|
|
7
7
|
id: 'usdt',
|
|
8
|
+
predictableActionArguments: true,
|
|
8
9
|
initial: 'loading',
|
|
9
10
|
context: {
|
|
10
11
|
paymentDetails: [],
|
|
@@ -74,8 +75,17 @@ export default function (request) {
|
|
|
74
75
|
{
|
|
75
76
|
actions: {
|
|
76
77
|
setPayment: assign((context, event) => {
|
|
77
|
-
const
|
|
78
|
-
const
|
|
78
|
+
const paymentDetails = Array.isArray(event.data) ? event.data : []
|
|
79
|
+
const currentPayment = paymentDetails.find((element) => element.category === context.currentCategory)
|
|
80
|
+
if (!currentPayment) {
|
|
81
|
+
return {
|
|
82
|
+
networks: [],
|
|
83
|
+
selectedNetwork: null,
|
|
84
|
+
currentPayment: null,
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const networkNames = Array.isArray(currentPayment.networkName) ? currentPayment.networkName : []
|
|
88
|
+
const defaultNetworks = networkNames.map((value, i) => {
|
|
79
89
|
return {
|
|
80
90
|
label: currentPayment.networkOptional?.[i],
|
|
81
91
|
value,
|
|
@@ -85,7 +95,7 @@ export default function (request) {
|
|
|
85
95
|
|
|
86
96
|
return {
|
|
87
97
|
networks: defaultNetworks,
|
|
88
|
-
selectedNetwork: defaultNetworks[0],
|
|
98
|
+
selectedNetwork: defaultNetworks[0] || null,
|
|
89
99
|
currentPayment,
|
|
90
100
|
}
|
|
91
101
|
}),
|
|
@@ -94,6 +104,9 @@ export default function (request) {
|
|
|
94
104
|
}),
|
|
95
105
|
setResultFromLocal: assign((context, event) => {
|
|
96
106
|
const { resultMap, selectedNetwork } = context
|
|
107
|
+
if (!selectedNetwork) {
|
|
108
|
+
return {}
|
|
109
|
+
}
|
|
97
110
|
return { result: resultMap[selectedNetwork.value] }
|
|
98
111
|
}),
|
|
99
112
|
setResult: assign((context, event) => {
|
|
@@ -121,6 +134,9 @@ export default function (request) {
|
|
|
121
134
|
guards: {
|
|
122
135
|
isFound: (context, event) => {
|
|
123
136
|
const { resultMap, selectedNetwork } = context
|
|
137
|
+
if (!selectedNetwork) {
|
|
138
|
+
return false
|
|
139
|
+
}
|
|
124
140
|
return resultMap[selectedNetwork.value]
|
|
125
141
|
},
|
|
126
142
|
},
|
|
@@ -130,6 +146,9 @@ export default function (request) {
|
|
|
130
146
|
},
|
|
131
147
|
submitDeposit: async (context, event) => {
|
|
132
148
|
const { currentPayment, selectedNetwork } = context
|
|
149
|
+
if (!currentPayment || !selectedNetwork) {
|
|
150
|
+
throw { code: 'ERR_INVALID_USDT_NETWORK' }
|
|
151
|
+
}
|
|
133
152
|
return await request.send(
|
|
134
153
|
payment.submitDepositTransactionCrypto({
|
|
135
154
|
method: currentPayment.method,
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { assign, createMachine } from 'xstate'
|
|
2
|
-
import payment from '
|
|
2
|
+
import payment from '../../api/payment.js'
|
|
3
3
|
|
|
4
4
|
export default function (request, context) {
|
|
5
5
|
const { paymentDetail = [] } = context || {}
|
|
6
6
|
return createMachine(
|
|
7
7
|
{
|
|
8
8
|
id: 'usdt',
|
|
9
|
+
predictableActionArguments: true,
|
|
9
10
|
initial: 'loading',
|
|
10
11
|
context: {
|
|
11
12
|
paymentDetail,
|
|
@@ -74,6 +75,13 @@ export default function (request, context) {
|
|
|
74
75
|
const currentPayment = context.paymentDetail.find(
|
|
75
76
|
(element) => element.transferType === 'deposit' && element.category === context.currentCategory
|
|
76
77
|
)
|
|
78
|
+
if (!currentPayment) {
|
|
79
|
+
return {
|
|
80
|
+
networks: [],
|
|
81
|
+
selectedNetwork: null,
|
|
82
|
+
currentPayment: null,
|
|
83
|
+
}
|
|
84
|
+
}
|
|
77
85
|
const defaultNetworks = currentPayment.networkName.map((value, i) => {
|
|
78
86
|
return {
|
|
79
87
|
label: currentPayment.networkOptional?.[i],
|
|
@@ -92,6 +100,9 @@ export default function (request, context) {
|
|
|
92
100
|
}),
|
|
93
101
|
setResultFromLocal: assign((context, event) => {
|
|
94
102
|
const { resultMap, selectedNetwork } = context
|
|
103
|
+
if (!selectedNetwork) {
|
|
104
|
+
return {}
|
|
105
|
+
}
|
|
95
106
|
return { result: resultMap[selectedNetwork.value] }
|
|
96
107
|
}),
|
|
97
108
|
setResult: assign((context, event) => {
|
|
@@ -118,6 +129,9 @@ export default function (request, context) {
|
|
|
118
129
|
guards: {
|
|
119
130
|
isFound: (context, event) => {
|
|
120
131
|
const { resultMap, selectedNetwork } = context
|
|
132
|
+
if (!selectedNetwork) {
|
|
133
|
+
return false
|
|
134
|
+
}
|
|
121
135
|
return resultMap[selectedNetwork.value]
|
|
122
136
|
},
|
|
123
137
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { assign, createMachine } from 'xstate'
|
|
2
|
-
import payment from '
|
|
3
|
-
import { max } from '
|
|
2
|
+
import payment from '../../api/payment.js'
|
|
3
|
+
import { max } from '../../util/index.js'
|
|
4
4
|
|
|
5
5
|
export default function (request, context) {
|
|
6
6
|
const { appSecret } = request.config
|
|
@@ -9,6 +9,7 @@ export default function (request, context) {
|
|
|
9
9
|
return createMachine(
|
|
10
10
|
{
|
|
11
11
|
id: 'virtual_bank_cash',
|
|
12
|
+
predictableActionArguments: true,
|
|
12
13
|
initial: 'loading',
|
|
13
14
|
context: {
|
|
14
15
|
siteConfig,
|
|
@@ -112,13 +113,13 @@ export default function (request, context) {
|
|
|
112
113
|
setInitData: assign((context, event) => {
|
|
113
114
|
const { currentPayment } = event.data
|
|
114
115
|
|
|
115
|
-
const processing = currentPayment?.processing?.[0]
|
|
116
|
+
const processing = currentPayment?.processing?.[0] || null
|
|
116
117
|
|
|
117
|
-
const virtualBanks = currentPayment?.virtualBanks?.[0]
|
|
118
|
+
const virtualBanks = currentPayment?.virtualBanks?.[0] || null
|
|
118
119
|
|
|
119
120
|
return {
|
|
120
121
|
currentPayment,
|
|
121
|
-
method: currentPayment
|
|
122
|
+
method: currentPayment?.method || null,
|
|
122
123
|
processing,
|
|
123
124
|
selectedAmount: max(promotion?.minimumAmount, currentPayment?.minimum, selectedAmount, 0),
|
|
124
125
|
virtualBanks,
|
|
@@ -163,10 +164,11 @@ export default function (request, context) {
|
|
|
163
164
|
},
|
|
164
165
|
guards: {
|
|
165
166
|
isCalculable: (context, event) => {
|
|
166
|
-
const {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
167
|
+
const { selectedAmount, currentPayment } = context
|
|
168
|
+
if (!currentPayment) {
|
|
169
|
+
return false
|
|
170
|
+
}
|
|
171
|
+
const { maximum, minimum } = currentPayment
|
|
170
172
|
return selectedAmount && minimum <= +selectedAmount && +selectedAmount <= maximum
|
|
171
173
|
},
|
|
172
174
|
isProcessing: (context, event) => {
|
|
@@ -7,6 +7,7 @@ export default function (request) {
|
|
|
7
7
|
return createMachine(
|
|
8
8
|
{
|
|
9
9
|
id: 'vpay',
|
|
10
|
+
predictableActionArguments: true,
|
|
10
11
|
initial: 'loading',
|
|
11
12
|
context: {
|
|
12
13
|
method: 'vpay',
|
|
@@ -304,6 +305,12 @@ export default function (request) {
|
|
|
304
305
|
calculation: null,
|
|
305
306
|
}
|
|
306
307
|
}),
|
|
308
|
+
reset: assign(() => {
|
|
309
|
+
return {
|
|
310
|
+
amount: 0,
|
|
311
|
+
calculation: null,
|
|
312
|
+
}
|
|
313
|
+
}),
|
|
307
314
|
},
|
|
308
315
|
guards: {
|
|
309
316
|
hasUserAccount: (context, event) => {
|
package/src/machine/error.js
CHANGED
|
@@ -5,6 +5,7 @@ export default function (request) {
|
|
|
5
5
|
return createMachine(
|
|
6
6
|
{
|
|
7
7
|
id: 'game_hot_new',
|
|
8
|
+
predictableActionArguments: true,
|
|
8
9
|
initial: 'preparing',
|
|
9
10
|
context: {
|
|
10
11
|
hot: {
|
|
@@ -45,8 +46,19 @@ export default function (request) {
|
|
|
45
46
|
actions: {
|
|
46
47
|
setId: assign((context, event) => {
|
|
47
48
|
const { list = [] } = event.data
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
let hotId
|
|
50
|
+
let newId
|
|
51
|
+
for (let i = 0; i < list.length; i++) {
|
|
52
|
+
const item = list[i]
|
|
53
|
+
if (hotId === undefined && item.category === context.hot.name) {
|
|
54
|
+
hotId = item.id
|
|
55
|
+
} else if (newId === undefined && item.category === context.new.name) {
|
|
56
|
+
newId = item.id
|
|
57
|
+
}
|
|
58
|
+
if (hotId !== undefined && newId !== undefined) {
|
|
59
|
+
break
|
|
60
|
+
}
|
|
61
|
+
}
|
|
50
62
|
return {
|
|
51
63
|
hot: { ...context.hot, id: hotId },
|
|
52
64
|
new: { ...context.new, id: newId },
|
package/src/machine/game_info.js
CHANGED
|
@@ -7,6 +7,7 @@ export default function (request, context) {
|
|
|
7
7
|
return createMachine(
|
|
8
8
|
{
|
|
9
9
|
id: 'game_info',
|
|
10
|
+
predictableActionArguments: true,
|
|
10
11
|
initial: 'fetching',
|
|
11
12
|
context: {
|
|
12
13
|
gameInfo: {},
|
|
@@ -49,6 +50,10 @@ export default function (request, context) {
|
|
|
49
50
|
services: {
|
|
50
51
|
// 取得遊戲資訊
|
|
51
52
|
fetchGameInfo: async (context, event) => {
|
|
53
|
+
// [防呆] 確保有 gameCode
|
|
54
|
+
if (!gameCode) {
|
|
55
|
+
return { data: {} }
|
|
56
|
+
}
|
|
52
57
|
return await request.send(game.getGameInfo({ appSecret, gameCode }))
|
|
53
58
|
},
|
|
54
59
|
},
|
|
@@ -5,6 +5,7 @@ export default function (request) {
|
|
|
5
5
|
return createMachine(
|
|
6
6
|
{
|
|
7
7
|
id: 'game_search_cash',
|
|
8
|
+
predictableActionArguments: true,
|
|
8
9
|
initial: 'init',
|
|
9
10
|
context: {
|
|
10
11
|
initialized: false,
|
|
@@ -352,8 +353,18 @@ export default function (request) {
|
|
|
352
353
|
fetchGamesByKeyword: async (context, event) => {
|
|
353
354
|
const { keyword, click, clickDefault, lang } = context
|
|
354
355
|
const tag = await request.send(game.getGameTags({ q: keyword, lang }))
|
|
356
|
+
const tagList = Array.isArray(tag?.result) ? tag.result : []
|
|
357
|
+
const firstTag = tagList[0]
|
|
358
|
+
if (!firstTag?.id) {
|
|
359
|
+
return {
|
|
360
|
+
tagId: null,
|
|
361
|
+
traceId: null,
|
|
362
|
+
gameList: [],
|
|
363
|
+
tagList,
|
|
364
|
+
}
|
|
365
|
+
}
|
|
355
366
|
|
|
356
|
-
const tagId =
|
|
367
|
+
const tagId = firstTag.id
|
|
357
368
|
const tagIndex = null
|
|
358
369
|
|
|
359
370
|
const { traceId, result } = await request.send(
|
|
@@ -370,7 +381,7 @@ export default function (request) {
|
|
|
370
381
|
tagId,
|
|
371
382
|
traceId,
|
|
372
383
|
gameList: result,
|
|
373
|
-
tagList
|
|
384
|
+
tagList,
|
|
374
385
|
}
|
|
375
386
|
},
|
|
376
387
|
sendTrace: async (context, event) => {
|