@jetthai/cuora 2.0.0-beta.1 → 2.0.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/.claude/commands/sync-ai-prompts.md +93 -0
- package/.claude/settings.local.json +23 -0
- package/.github/copilot-instructions.md +405 -0
- package/.husky/post-checkout +32 -0
- package/.husky/pre-commit +1 -3
- package/.husky/pre-push +36 -0
- package/AGENTS.md +405 -0
- package/AI_PROMPT_SOURCE.md +403 -0
- package/CHANGELOG.md +274 -3
- package/CLAUDE.md +405 -0
- package/GEMINI.md +405 -0
- package/README.md +299 -15
- package/docs/kibana/crypto-way-deposit-amount-bug-analysis.md +1003 -0
- package/docs/kibana/play-providerId-error.md +202 -0
- package/docs/kibana/play-selectedWalletType.md +1 -0
- package/docs/kibana/play-selectedWalletType_2.md +1 -0
- package/docs/kibana/play-selectedWalletType_analysis.md +565 -0
- package/package.json +3 -3
- package/scripts/auto-version.js +68 -0
- package/scripts/auto-version.sh +33 -0
- package/scripts/branch-auto-npm-publish.js +29 -0
- package/scripts/check-version.sh +36 -0
- package/scripts/clean-tags.sh +84 -0
- package/src/api/account.js +0 -1
- package/src/api/activity.js +22 -37
- package/src/api/auth.js +5 -36
- package/src/api/common.js +5 -3
- package/src/api/game.js +0 -10
- package/src/api/payment.js +17 -55
- package/src/api/user.js +10 -16
- package/src/index.js +2 -2
- package/src/machine/activity/activity_cash.js +84 -36
- package/src/machine/activity/cash_rain_activity.js +0 -1
- package/src/machine/activity/continue_deposit_activity.js +0 -1
- package/src/machine/activity/deposit_activity.js +0 -1
- package/src/machine/activity/diamond_shop_activity_cash.js +0 -8
- package/src/machine/activity/fafafa_activity.js +0 -11
- package/src/machine/activity/friend_invite_friends_activity.js +8 -7
- package/src/machine/activity/index.js +0 -12
- package/src/machine/activity/instant_rebate_activity.js +0 -1
- package/src/machine/activity/jackpot.js +0 -1
- package/src/machine/activity/otp_verified_activity.js +0 -1
- package/src/machine/activity/ranking_activity.js +0 -1
- package/src/machine/activity/roulette_activity_v2.js +0 -1
- package/src/machine/activity/sign_in_activity.js +0 -1
- package/src/machine/activity/sign_in_monthly_activity.js +1 -2
- package/src/machine/activity/specify_bets_activity.js +0 -1
- package/src/machine/activity/specify_turnover_activity.js +0 -1
- package/src/machine/activity/time_bomb_activity.js +0 -1
- package/src/machine/activity/vip_card_activity.js +0 -1
- package/src/machine/auth.js +112 -113
- package/src/machine/auth_otp_v3.js +11 -8
- package/src/machine/bank_binding.js +2 -3
- package/src/machine/common.js +14 -112
- package/src/machine/deposit/crypto_bank_cash.js +20 -35
- package/src/machine/deposit/crypto_qrcode_cash.js +26 -64
- package/src/machine/deposit/crypto_way_cash.js +48 -37
- package/src/machine/deposit/direct_cash.js +8 -10
- package/src/machine/deposit/index.js +0 -28
- package/src/machine/deposit/loadcard_cash.js +14 -32
- package/src/machine/deposit/manual_cash.js +18 -28
- package/src/machine/deposit/qrcode_cash.js +15 -32
- package/src/machine/deposit/usdt_cash.js +1 -15
- package/src/machine/deposit/virtual_bank_cash.js +13 -12
- package/src/machine/error.js +7 -1
- package/src/machine/game_betslip.js +0 -1
- package/src/machine/game_favorite_v2.js +0 -1
- package/src/machine/game_info.js +1 -13
- package/src/machine/game_search_cash.js +2 -13
- package/src/machine/game_v2_1.js +42 -166
- package/src/machine/honor_board_cash.js +8 -11
- package/src/machine/inbox.js +43 -105
- package/src/machine/index.js +0 -32
- package/src/machine/leaderboard.js +8 -12
- package/src/machine/navbar.js +1 -3
- package/src/machine/ranking.js +45 -30
- package/src/machine/reward_cash.js +0 -40
- package/src/machine/roulette_v2.js +14 -11
- package/src/machine/setting.js +0 -1
- package/src/machine/side_cash.js +3 -3
- package/src/machine/user_info.js +0 -1
- package/src/machine/user_photo.js +0 -1
- package/src/machine/user_reset_password.js +0 -14
- package/src/machine/user_sign_up.js +46 -61
- package/src/machine/websocket.js +18 -62
- package/src/machine/withdraw/index.js +0 -6
- package/src/machine/withdraw/withdraw_manual_cash.js +59 -39
- package/src/request/config.js +2 -0
- package/src/request/request.js +49 -60
- package/src/util/amount.js +8 -0
- package/src/util/constant.js +0 -1
- package/src/util/err998SentryExtra.js +26 -0
- package/src/util/index.js +2 -4
- package/src/util/paramStore.js +139 -0
- package/src/util/storage.js +3 -4
- package/BREAKING_CHANGES.md +0 -9
- package/resetGitBranch.sh +0 -101
- package/src/lib/fingerprint_v3_11_12.js +0 -11433
- package/src/machine/activity/activity.js +0 -213
- package/src/machine/activity/diamond_shop_activity_fc.js +0 -197
- package/src/machine/activity/diamond_shop_activity_vn.js +0 -179
- package/src/machine/activity/invite_friends_activity.js +0 -115
- package/src/machine/activity/mini_game_activity.js +0 -69
- package/src/machine/activity/return_bonus_activity.js +0 -155
- package/src/machine/auth_otp_v2.js +0 -178
- package/src/machine/bank_binding_amb.js +0 -146
- package/src/machine/bonus.js +0 -76
- package/src/machine/deposit/amb.js +0 -93
- package/src/machine/deposit/crypto_bank.js +0 -340
- package/src/machine/deposit/crypto_qrcode.js +0 -158
- package/src/machine/deposit/crypto_way.js +0 -253
- package/src/machine/deposit/deposit_fc.js +0 -272
- package/src/machine/deposit/direct.js +0 -311
- package/src/machine/deposit/float.js +0 -375
- package/src/machine/deposit/krway.js +0 -152
- package/src/machine/deposit/loadcard_vn.js +0 -352
- package/src/machine/deposit/manual_vn.js +0 -463
- package/src/machine/deposit/qrcode_v2.js +0 -339
- package/src/machine/deposit/usdt.js +0 -163
- package/src/machine/deposit/virtual_bank_vn.js +0 -270
- package/src/machine/deposit/vpay.js +0 -374
- package/src/machine/game_hot_new.js +0 -91
- package/src/machine/game_replay.js +0 -47
- package/src/machine/game_search_v2.js +0 -402
- package/src/machine/honor_board.js +0 -144
- package/src/machine/merge.js +0 -58
- package/src/machine/payment_data.js +0 -87
- package/src/machine/promotions.js +0 -163
- package/src/machine/reward.js +0 -256
- package/src/machine/reward_fc.js +0 -99
- package/src/machine/side.js +0 -160
- package/src/machine/side_v2.js +0 -223
- package/src/machine/vip_table.js +0 -58
- package/src/machine/welcome.js +0 -111
- package/src/machine/withdraw/withdraw_crypto_cash.js +0 -328
- package/src/machine/withdraw/withdraw_krway.js +0 -223
- package/src/machine/withdraw/withdraw_manual.js +0 -541
- package/src/util/deviceToken.js +0 -60
- package/src/util/math.js +0 -4
- package/test/api.behavior.test.js +0 -69
- package/test/api.contract.test.js +0 -18
- package/test/config.test.js +0 -27
- package/test/deviceToken.test.js +0 -139
- package/test/helpers.coverage.test.js +0 -11
- package/test/helpers.js +0 -91
- package/test/index.exports.test.js +0 -14
- package/test/machine.activity.core.coverage.test.js +0 -337
- package/test/machine.activity.gap.coverage.test.js +0 -252
- package/test/machine.activity.more.coverage.test.js +0 -180
- package/test/machine.activity_plus_and_binding_amb.coverage.test.js +0 -201
- package/test/machine.activity_timer_bonus.coverage.test.js +0 -136
- package/test/machine.activity_welcome.low.coverage.test.js +0 -211
- package/test/machine.amb_rewardfc_websocket.more.coverage.test.js +0 -201
- package/test/machine.auth.coverage.test.js +0 -215
- package/test/machine.bank_binding.test.js +0 -143
- package/test/machine.binding_otp_krway.coverage.test.js +0 -223
- package/test/machine.contract.test.js +0 -50
- package/test/machine.crypto_bank.coverage.test.js +0 -270
- package/test/machine.crypto_way.coverage.test.js +0 -108
- package/test/machine.crypto_way_cash.coverage.test.js +0 -114
- package/test/machine.definition.test.js +0 -137
- package/test/machine.deposit.manual.coverage.test.js +0 -365
- package/test/machine.deposit_fc.coverage.test.js +0 -126
- package/test/machine.direct.coverage.test.js +0 -96
- package/test/machine.direct_cash.coverage.test.js +0 -108
- package/test/machine.error.coverage.test.js +0 -37
- package/test/machine.events.test.js +0 -126
- package/test/machine.favorite_jackpot.coverage.test.js +0 -82
- package/test/machine.float.coverage.test.js +0 -136
- package/test/machine.flow.test.js +0 -226
- package/test/machine.game_hot_new_vip_table.coverage.test.js +0 -105
- package/test/machine.game_search_cash.coverage.test.js +0 -195
- package/test/machine.game_search_v2.test.js +0 -199
- package/test/machine.game_user_profile.coverage.test.js +0 -100
- package/test/machine.honor_board.test.js +0 -148
- package/test/machine.inbox.common.coverage.test.js +0 -304
- package/test/machine.loadcard_cash.coverage.test.js +0 -101
- package/test/machine.loadcard_vn.coverage.test.js +0 -122
- package/test/machine.misc.coverage.test.js +0 -361
- package/test/machine.more2.coverage.test.js +0 -261
- package/test/machine.options.execution.test.js +0 -272
- package/test/machine.priority.coverage.test.js +0 -629
- package/test/machine.qrcode_cash.coverage.test.js +0 -107
- package/test/machine.qrcode_v2.coverage.test.js +0 -121
- package/test/machine.regression.test.js +0 -82
- package/test/machine.roulette_v2.test.js +0 -142
- package/test/machine.side_reward_reset.coverage.test.js +0 -220
- package/test/machine.targeted.coverage.test.js +0 -313
- package/test/machine.usdt.coverage.test.js +0 -95
- package/test/machine.usdt_cash.coverage.test.js +0 -73
- package/test/machine.vip_card_activity.test.js +0 -114
- package/test/machine.virtual_bank_cash.coverage.test.js +0 -105
- package/test/machine.virtual_bank_vn.coverage.test.js +0 -105
- package/test/machine.vpay.coverage.test.js +0 -142
- package/test/machine.withdraw_crypto_cash.coverage.test.js +0 -166
- package/test/machine.withdraw_krway.coverage.test.js +0 -123
- package/test/machine.withdraw_manual.coverage.test.js +0 -185
- package/test/machine.withdraw_manual_cash.coverage.test.js +0 -123
- package/test/request.test.js +0 -325
- package/test/util.storage.errors.test.js +0 -47
- package/test/util.test.js +0 -41
|
@@ -1,339 +0,0 @@
|
|
|
1
|
-
import { assign, createMachine } from 'xstate'
|
|
2
|
-
import payment from '../../api/payment.js'
|
|
3
|
-
import common from '../../api/common.js'
|
|
4
|
-
|
|
5
|
-
export default function (request) {
|
|
6
|
-
const { appSecret } = request.config
|
|
7
|
-
return createMachine(
|
|
8
|
-
{
|
|
9
|
-
id: 'qrcode',
|
|
10
|
-
predictableActionArguments: true,
|
|
11
|
-
initial: 'loading',
|
|
12
|
-
context: {
|
|
13
|
-
siteConfig: null,
|
|
14
|
-
qrcodes: null,
|
|
15
|
-
options: null,
|
|
16
|
-
|
|
17
|
-
selectedQrcode: null,
|
|
18
|
-
selectedAmount: null,
|
|
19
|
-
|
|
20
|
-
calculation: null,
|
|
21
|
-
|
|
22
|
-
paymentDetail: [],
|
|
23
|
-
currentCategory: 'qrcode',
|
|
24
|
-
currentMethod: null,
|
|
25
|
-
|
|
26
|
-
result: null,
|
|
27
|
-
|
|
28
|
-
grandTotalEnable: 1,
|
|
29
|
-
|
|
30
|
-
// use for wallet mode 3 & 4
|
|
31
|
-
promotion: null,
|
|
32
|
-
bonusPreviewData: [],
|
|
33
|
-
},
|
|
34
|
-
states: {
|
|
35
|
-
loading: {
|
|
36
|
-
invoke: {
|
|
37
|
-
src: 'fetchInitData',
|
|
38
|
-
onDone: {
|
|
39
|
-
target: 'checking',
|
|
40
|
-
actions: 'setInitData',
|
|
41
|
-
},
|
|
42
|
-
onError: {
|
|
43
|
-
target: 'fail',
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
checking: {
|
|
48
|
-
always: [
|
|
49
|
-
{
|
|
50
|
-
target: 'fetching',
|
|
51
|
-
cond: (context, event) => {
|
|
52
|
-
const { siteConfig = {}, promotion = {}, selectedQrcode } = context
|
|
53
|
-
const { bonusPreviewEnable } = siteConfig
|
|
54
|
-
return !!selectedQrcode && bonusPreviewEnable && promotion.activityNo != 'none'
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
{ target: 'loaded' },
|
|
58
|
-
],
|
|
59
|
-
},
|
|
60
|
-
fetching: {
|
|
61
|
-
invoke: {
|
|
62
|
-
src: 'fetchBonusPreview',
|
|
63
|
-
onDone: {
|
|
64
|
-
target: 'loaded',
|
|
65
|
-
actions: 'setBonusPreview',
|
|
66
|
-
},
|
|
67
|
-
onError: {
|
|
68
|
-
target: 'loaded',
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
fail: {},
|
|
73
|
-
loaded: {
|
|
74
|
-
entry: 'reset',
|
|
75
|
-
on: {
|
|
76
|
-
SELECT_QRCODE: [
|
|
77
|
-
{
|
|
78
|
-
target: 'fetching',
|
|
79
|
-
actions: 'setQrcode',
|
|
80
|
-
cond: (context, event) => {
|
|
81
|
-
const { siteConfig = {}, promotion = {} } = context
|
|
82
|
-
const { bonusPreviewEnable } = siteConfig
|
|
83
|
-
return bonusPreviewEnable && promotion.activityNo != 'none'
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
actions: 'setQrcode',
|
|
88
|
-
},
|
|
89
|
-
],
|
|
90
|
-
SELECT_AMOUNT: [
|
|
91
|
-
{
|
|
92
|
-
target: 'debouncing',
|
|
93
|
-
actions: 'setAmount',
|
|
94
|
-
},
|
|
95
|
-
],
|
|
96
|
-
KEY_IN: [
|
|
97
|
-
{
|
|
98
|
-
target: 'calculating',
|
|
99
|
-
actions: 'setAmount',
|
|
100
|
-
},
|
|
101
|
-
],
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
debouncing: {
|
|
105
|
-
on: {
|
|
106
|
-
SELECT_AMOUNT: [
|
|
107
|
-
{
|
|
108
|
-
target: 'debouncing',
|
|
109
|
-
actions: 'setAmount',
|
|
110
|
-
},
|
|
111
|
-
],
|
|
112
|
-
BACK: {
|
|
113
|
-
target: 'loaded',
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
after: {
|
|
117
|
-
1000: {
|
|
118
|
-
target: 'calculating',
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
calculable: {
|
|
123
|
-
entry: 'clearCalculation',
|
|
124
|
-
on: {
|
|
125
|
-
SELECT_AMOUNT: [
|
|
126
|
-
{
|
|
127
|
-
target: 'debouncing',
|
|
128
|
-
actions: 'setAmount',
|
|
129
|
-
},
|
|
130
|
-
],
|
|
131
|
-
KEY_IN: {
|
|
132
|
-
target: 'calculating',
|
|
133
|
-
actions: 'setAmount',
|
|
134
|
-
},
|
|
135
|
-
BACK: {
|
|
136
|
-
target: 'loaded',
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
calculating: {
|
|
141
|
-
invoke: {
|
|
142
|
-
src: 'fetchCalculation',
|
|
143
|
-
onDone: [
|
|
144
|
-
{
|
|
145
|
-
target: 'calculated',
|
|
146
|
-
actions: 'setCalculation',
|
|
147
|
-
},
|
|
148
|
-
],
|
|
149
|
-
onError: {
|
|
150
|
-
target: 'calculable',
|
|
151
|
-
},
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
calculated: {
|
|
155
|
-
on: {
|
|
156
|
-
SELECT_AMOUNT: [
|
|
157
|
-
{
|
|
158
|
-
target: 'debouncing',
|
|
159
|
-
actions: 'addAmount',
|
|
160
|
-
cond: 'isGrandTotalEnable',
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
target: 'debouncing',
|
|
164
|
-
actions: 'setAmount',
|
|
165
|
-
},
|
|
166
|
-
],
|
|
167
|
-
KEY_IN: {
|
|
168
|
-
target: 'calculating',
|
|
169
|
-
actions: 'setAmount',
|
|
170
|
-
},
|
|
171
|
-
CONFIRM: {
|
|
172
|
-
target: 'submitting',
|
|
173
|
-
},
|
|
174
|
-
BACK: {
|
|
175
|
-
target: 'loaded',
|
|
176
|
-
},
|
|
177
|
-
CLEAR_CALCULATION: {
|
|
178
|
-
target: 'debouncing',
|
|
179
|
-
actions: 'clearCalculation',
|
|
180
|
-
},
|
|
181
|
-
},
|
|
182
|
-
},
|
|
183
|
-
submitting: {
|
|
184
|
-
invoke: {
|
|
185
|
-
src: 'submitDeposit',
|
|
186
|
-
onDone: {
|
|
187
|
-
target: 'submitted',
|
|
188
|
-
actions: 'setResult',
|
|
189
|
-
},
|
|
190
|
-
onError: {
|
|
191
|
-
target: 'loaded',
|
|
192
|
-
},
|
|
193
|
-
},
|
|
194
|
-
},
|
|
195
|
-
submitted: {
|
|
196
|
-
on: {
|
|
197
|
-
SELECT_QRCODE: [
|
|
198
|
-
{
|
|
199
|
-
target: 'fetching',
|
|
200
|
-
actions: 'setQrcode',
|
|
201
|
-
cond: (context, event) => {
|
|
202
|
-
const { siteConfig = {}, promotion = {} } = context
|
|
203
|
-
const { bonusPreviewEnable } = siteConfig
|
|
204
|
-
return bonusPreviewEnable && promotion.activityNo != 'none'
|
|
205
|
-
},
|
|
206
|
-
},
|
|
207
|
-
{
|
|
208
|
-
target: 'loaded',
|
|
209
|
-
actions: 'setQrcode',
|
|
210
|
-
},
|
|
211
|
-
],
|
|
212
|
-
},
|
|
213
|
-
},
|
|
214
|
-
},
|
|
215
|
-
on: {
|
|
216
|
-
SET_PROMOTION: {
|
|
217
|
-
actions: 'setPromotion',
|
|
218
|
-
},
|
|
219
|
-
},
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
actions: {
|
|
223
|
-
reset: assign((context, event) => {
|
|
224
|
-
return {
|
|
225
|
-
selectedAmount: null,
|
|
226
|
-
calculation: null,
|
|
227
|
-
result: null,
|
|
228
|
-
}
|
|
229
|
-
}),
|
|
230
|
-
setInitData: assign((context, event) => {
|
|
231
|
-
const { siteConfig, paymentDetail } = event.data
|
|
232
|
-
const qrcodes = paymentDetail.filter((element) => element.category === context.currentCategory)
|
|
233
|
-
const selectedQrcode = qrcodes[0]
|
|
234
|
-
return {
|
|
235
|
-
siteConfig,
|
|
236
|
-
paymentDetail,
|
|
237
|
-
qrcodes,
|
|
238
|
-
selectedQrcode,
|
|
239
|
-
currentMethod: selectedQrcode?.method,
|
|
240
|
-
options: selectedQrcode?.optional,
|
|
241
|
-
grandTotalEnable: selectedQrcode?.grandTotalEnable,
|
|
242
|
-
}
|
|
243
|
-
}),
|
|
244
|
-
setBonusPreview: assign((context, event) => {
|
|
245
|
-
return {
|
|
246
|
-
bonusPreviewData: event.data,
|
|
247
|
-
}
|
|
248
|
-
}),
|
|
249
|
-
setQrcode: assign((context, event) => {
|
|
250
|
-
return {
|
|
251
|
-
selectedQrcode: event.data,
|
|
252
|
-
currentMethod: event.data.method,
|
|
253
|
-
options: event.data.optional,
|
|
254
|
-
grandTotalEnable: event.data.grandTotalEnable,
|
|
255
|
-
}
|
|
256
|
-
}),
|
|
257
|
-
addAmount: assign((context, event) => {
|
|
258
|
-
return { selectedAmount: (context.selectedAmount || 0) + event.data }
|
|
259
|
-
}),
|
|
260
|
-
setAmount: assign((context, event) => {
|
|
261
|
-
return { selectedAmount: event.data }
|
|
262
|
-
}),
|
|
263
|
-
setCalculation: assign((context, event) => {
|
|
264
|
-
// V2接口轉換中回傳的資料結構不同
|
|
265
|
-
const { data } = event.data
|
|
266
|
-
if (data) {
|
|
267
|
-
return {
|
|
268
|
-
calculation: data,
|
|
269
|
-
}
|
|
270
|
-
} else {
|
|
271
|
-
return {
|
|
272
|
-
calculation: event.data,
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
}),
|
|
276
|
-
clearCalculation: assign((context, event) => {
|
|
277
|
-
return {
|
|
278
|
-
calculation: null,
|
|
279
|
-
}
|
|
280
|
-
}),
|
|
281
|
-
setResult: assign((context, event) => {
|
|
282
|
-
return {
|
|
283
|
-
result: event.data,
|
|
284
|
-
}
|
|
285
|
-
}),
|
|
286
|
-
setPromotion: assign((context, event) => {
|
|
287
|
-
const promotion = event.data
|
|
288
|
-
return {
|
|
289
|
-
promotion,
|
|
290
|
-
}
|
|
291
|
-
}),
|
|
292
|
-
},
|
|
293
|
-
guards: {
|
|
294
|
-
isGrandTotalEnable: (context, event) => {
|
|
295
|
-
return context.grandTotalEnable === 1
|
|
296
|
-
},
|
|
297
|
-
},
|
|
298
|
-
services: {
|
|
299
|
-
fetchInitData: async (context, event) => {
|
|
300
|
-
const [{ config }, paymentDetail = []] = await Promise.all([
|
|
301
|
-
request.send(common.getConfig({ appSecret })),
|
|
302
|
-
request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' })),
|
|
303
|
-
])
|
|
304
|
-
const siteConfig = JSON.parse(window.atob(config))
|
|
305
|
-
return { siteConfig, paymentDetail }
|
|
306
|
-
},
|
|
307
|
-
fetchBonusPreview: async (context, event) => {
|
|
308
|
-
const { currentMethod, promotion } = context
|
|
309
|
-
return await request.send(
|
|
310
|
-
payment.getBonusPreview({
|
|
311
|
-
method: currentMethod,
|
|
312
|
-
promotionsNo: promotion?.activityNo,
|
|
313
|
-
})
|
|
314
|
-
)
|
|
315
|
-
},
|
|
316
|
-
fetchCalculation: async (context, event) => {
|
|
317
|
-
const { currentMethod, selectedAmount, promotion } = context
|
|
318
|
-
return await request.send(
|
|
319
|
-
payment.getDepositExpectedResult({
|
|
320
|
-
method: currentMethod,
|
|
321
|
-
amount: Number(selectedAmount),
|
|
322
|
-
promotionsNo: promotion?.activityNo,
|
|
323
|
-
})
|
|
324
|
-
)
|
|
325
|
-
},
|
|
326
|
-
submitDeposit: async (context, event) => {
|
|
327
|
-
const { currentMethod, selectedAmount, promotion } = context
|
|
328
|
-
return await request.send(
|
|
329
|
-
payment.submitDepositTransaction({
|
|
330
|
-
method: currentMethod,
|
|
331
|
-
amount: selectedAmount,
|
|
332
|
-
promotionsNo: promotion?.activityNo,
|
|
333
|
-
})
|
|
334
|
-
)
|
|
335
|
-
},
|
|
336
|
-
},
|
|
337
|
-
}
|
|
338
|
-
)
|
|
339
|
-
}
|
|
@@ -1,163 +0,0 @@
|
|
|
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: 'usdt',
|
|
8
|
-
predictableActionArguments: true,
|
|
9
|
-
initial: 'loading',
|
|
10
|
-
context: {
|
|
11
|
-
paymentDetails: [],
|
|
12
|
-
currentCategory: 'usdt',
|
|
13
|
-
currentPayment: null,
|
|
14
|
-
networks: [],
|
|
15
|
-
selectedNetwork: null,
|
|
16
|
-
|
|
17
|
-
resultMap: {},
|
|
18
|
-
result: {
|
|
19
|
-
action: '',
|
|
20
|
-
cdtime: null,
|
|
21
|
-
accountNumber: '', // crypto address
|
|
22
|
-
currency: '',
|
|
23
|
-
network: '',
|
|
24
|
-
name: '',
|
|
25
|
-
qrcode: '',
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
states: {
|
|
29
|
-
loading: {
|
|
30
|
-
invoke: {
|
|
31
|
-
src: 'fetchPayments',
|
|
32
|
-
onDone: {
|
|
33
|
-
target: 'fetching',
|
|
34
|
-
actions: 'setPayment',
|
|
35
|
-
},
|
|
36
|
-
onError: {
|
|
37
|
-
target: '#usdt.fail',
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
finding: {
|
|
42
|
-
always: [
|
|
43
|
-
{
|
|
44
|
-
target: 'idle',
|
|
45
|
-
actions: 'setResultFromLocal',
|
|
46
|
-
cond: 'isFound',
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
target: 'fetching',
|
|
50
|
-
},
|
|
51
|
-
],
|
|
52
|
-
},
|
|
53
|
-
fetching: {
|
|
54
|
-
invoke: {
|
|
55
|
-
src: 'submitDeposit',
|
|
56
|
-
onDone: {
|
|
57
|
-
target: 'idle',
|
|
58
|
-
actions: 'setResult',
|
|
59
|
-
},
|
|
60
|
-
onError: {
|
|
61
|
-
target: 'idle',
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
idle: {},
|
|
66
|
-
fail: {},
|
|
67
|
-
},
|
|
68
|
-
on: {
|
|
69
|
-
SET_NETWORK: {
|
|
70
|
-
target: '.finding',
|
|
71
|
-
actions: 'setNetwork',
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
actions: {
|
|
77
|
-
setPayment: assign((context, event) => {
|
|
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) => {
|
|
89
|
-
return {
|
|
90
|
-
label: currentPayment.networkOptional?.[i],
|
|
91
|
-
value,
|
|
92
|
-
icon: value,
|
|
93
|
-
}
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
return {
|
|
97
|
-
networks: defaultNetworks,
|
|
98
|
-
selectedNetwork: defaultNetworks[0] || null,
|
|
99
|
-
currentPayment,
|
|
100
|
-
}
|
|
101
|
-
}),
|
|
102
|
-
setNetwork: assign((context, event) => {
|
|
103
|
-
return { selectedNetwork: event.data }
|
|
104
|
-
}),
|
|
105
|
-
setResultFromLocal: assign((context, event) => {
|
|
106
|
-
const { resultMap, selectedNetwork } = context
|
|
107
|
-
if (!selectedNetwork) {
|
|
108
|
-
return {}
|
|
109
|
-
}
|
|
110
|
-
return { result: resultMap[selectedNetwork.value] }
|
|
111
|
-
}),
|
|
112
|
-
setResult: assign((context, event) => {
|
|
113
|
-
const { resultMap, selectedNetwork } = context
|
|
114
|
-
const { action, cdtime, accountNumber, currency, network, name, qrcode } = event.data
|
|
115
|
-
const result = {
|
|
116
|
-
action,
|
|
117
|
-
cdtime,
|
|
118
|
-
accountNumber,
|
|
119
|
-
currency,
|
|
120
|
-
network,
|
|
121
|
-
name,
|
|
122
|
-
qrcode,
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return {
|
|
126
|
-
result,
|
|
127
|
-
resultMap: {
|
|
128
|
-
...resultMap,
|
|
129
|
-
[selectedNetwork.value]: result,
|
|
130
|
-
},
|
|
131
|
-
}
|
|
132
|
-
}),
|
|
133
|
-
},
|
|
134
|
-
guards: {
|
|
135
|
-
isFound: (context, event) => {
|
|
136
|
-
const { resultMap, selectedNetwork } = context
|
|
137
|
-
if (!selectedNetwork) {
|
|
138
|
-
return false
|
|
139
|
-
}
|
|
140
|
-
return resultMap[selectedNetwork.value]
|
|
141
|
-
},
|
|
142
|
-
},
|
|
143
|
-
services: {
|
|
144
|
-
fetchPayments: async (context, event) => {
|
|
145
|
-
return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
|
|
146
|
-
},
|
|
147
|
-
submitDeposit: async (context, event) => {
|
|
148
|
-
const { currentPayment, selectedNetwork } = context
|
|
149
|
-
if (!currentPayment || !selectedNetwork) {
|
|
150
|
-
throw { code: 'ERR_INVALID_USDT_NETWORK' }
|
|
151
|
-
}
|
|
152
|
-
return await request.send(
|
|
153
|
-
payment.submitDepositTransactionCrypto({
|
|
154
|
-
method: currentPayment.method,
|
|
155
|
-
cryptoCurrency: currentPayment.channel,
|
|
156
|
-
cryptoNetwork: selectedNetwork.value,
|
|
157
|
-
})
|
|
158
|
-
)
|
|
159
|
-
},
|
|
160
|
-
},
|
|
161
|
-
}
|
|
162
|
-
)
|
|
163
|
-
}
|