@jetthai/cuora 2.0.0-beta.0 → 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 -112
- package/src/machine/auth_otp_v3.js +11 -8
- package/src/machine/bank_binding.js +2 -3
- package/src/machine/common.js +14 -98
- 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 +8 -11
- 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 +0 -1
- package/src/machine/game_v2_1.js +39 -126
- 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 -459
- 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 -80
- package/src/machine/game_replay.js +0 -47
- package/src/machine/game_search_v2.js +0 -402
- package/src/machine/honor_board.js +0 -133
- 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 -155
- 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 -133
- 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 -603
- 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,328 +0,0 @@
|
|
|
1
|
-
import { assign, createMachine } from 'xstate'
|
|
2
|
-
import payment from '../../api/payment.js'
|
|
3
|
-
import user from '../../api/user.js'
|
|
4
|
-
import api from '../../api/payment.js'
|
|
5
|
-
|
|
6
|
-
export default function (request, context) {
|
|
7
|
-
const { paymentDetail = [] } = context || {}
|
|
8
|
-
return createMachine(
|
|
9
|
-
{
|
|
10
|
-
id: 'withdraw_crypto_cash',
|
|
11
|
-
predictableActionArguments: true,
|
|
12
|
-
initial: 'loading',
|
|
13
|
-
context: {
|
|
14
|
-
paymentDetail,
|
|
15
|
-
withdrawRule: null,
|
|
16
|
-
selectedCrypto: null,
|
|
17
|
-
networks: [],
|
|
18
|
-
selectedNetwork: null,
|
|
19
|
-
address: '',
|
|
20
|
-
selectedAmount: null,
|
|
21
|
-
calculation: null,
|
|
22
|
-
processing: null,
|
|
23
|
-
|
|
24
|
-
// otp
|
|
25
|
-
requestId: null,
|
|
26
|
-
status: null,
|
|
27
|
-
target: null,
|
|
28
|
-
ttl: null,
|
|
29
|
-
},
|
|
30
|
-
states: {
|
|
31
|
-
loading: {
|
|
32
|
-
invoke: {
|
|
33
|
-
src: 'fetchInitData',
|
|
34
|
-
onDone: {
|
|
35
|
-
target: 'checking',
|
|
36
|
-
actions: 'setInitData',
|
|
37
|
-
},
|
|
38
|
-
onError: {
|
|
39
|
-
target: 'loaded',
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
checking: {
|
|
44
|
-
always: [{ target: 'submitted', cond: 'isProcessing' }, { target: 'loaded' }],
|
|
45
|
-
},
|
|
46
|
-
loaded: {},
|
|
47
|
-
debouncing: {
|
|
48
|
-
after: {
|
|
49
|
-
1000: [
|
|
50
|
-
{
|
|
51
|
-
target: 'calculating',
|
|
52
|
-
cond: 'isCalculable',
|
|
53
|
-
},
|
|
54
|
-
{ target: 'loaded' },
|
|
55
|
-
],
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
calculating: {
|
|
59
|
-
entry: 'resetCharge',
|
|
60
|
-
invoke: {
|
|
61
|
-
src: 'fetchCalculation',
|
|
62
|
-
onDone: {
|
|
63
|
-
target: 'calculated',
|
|
64
|
-
actions: 'setCalculation',
|
|
65
|
-
},
|
|
66
|
-
onError: {
|
|
67
|
-
target: 'calculated',
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
calculated: {
|
|
72
|
-
on: {
|
|
73
|
-
SUBMIT: [
|
|
74
|
-
{
|
|
75
|
-
target: 'submitting',
|
|
76
|
-
},
|
|
77
|
-
],
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
submitting: {
|
|
81
|
-
invoke: {
|
|
82
|
-
src: 'submitWithdraw',
|
|
83
|
-
onDone: [
|
|
84
|
-
{
|
|
85
|
-
target: 'otp',
|
|
86
|
-
actions: 'setOtp',
|
|
87
|
-
cond: 'isOtpRequired',
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
target: 'submitted',
|
|
91
|
-
actions: 'setProcessing',
|
|
92
|
-
},
|
|
93
|
-
],
|
|
94
|
-
onError: {
|
|
95
|
-
target: 'loaded',
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
submitted: {},
|
|
100
|
-
otp: {
|
|
101
|
-
type: 'parallel',
|
|
102
|
-
states: {
|
|
103
|
-
countdown: {
|
|
104
|
-
after: {
|
|
105
|
-
1000: {
|
|
106
|
-
target: 'countdown',
|
|
107
|
-
actions: 'decreaseTtl',
|
|
108
|
-
cond: (context) => context.ttl > 0,
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
verification: {
|
|
113
|
-
initial: 'idle',
|
|
114
|
-
states: {
|
|
115
|
-
idle: {
|
|
116
|
-
on: {
|
|
117
|
-
ACKNOWLEDGE: {
|
|
118
|
-
target: 'acknowledging',
|
|
119
|
-
},
|
|
120
|
-
RESET_OTP: {
|
|
121
|
-
target: 'reset',
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
acknowledging: {
|
|
126
|
-
invoke: {
|
|
127
|
-
src: 'acknowledge',
|
|
128
|
-
onDone: [
|
|
129
|
-
{
|
|
130
|
-
target: '#withdraw_crypto_cash.submitted',
|
|
131
|
-
},
|
|
132
|
-
],
|
|
133
|
-
onError: {
|
|
134
|
-
target: 'idle',
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
reset: {
|
|
139
|
-
invoke: {
|
|
140
|
-
src: 'resetOtp',
|
|
141
|
-
onDone: {
|
|
142
|
-
target: 'idle',
|
|
143
|
-
actions: 'setVerificationData',
|
|
144
|
-
},
|
|
145
|
-
onError: { target: 'idle' },
|
|
146
|
-
},
|
|
147
|
-
},
|
|
148
|
-
},
|
|
149
|
-
},
|
|
150
|
-
},
|
|
151
|
-
},
|
|
152
|
-
},
|
|
153
|
-
on: {
|
|
154
|
-
SET_NETWORK: {
|
|
155
|
-
target: 'debouncing',
|
|
156
|
-
actions: 'setNetwork',
|
|
157
|
-
internal: false,
|
|
158
|
-
},
|
|
159
|
-
SET_ADDRESS: {
|
|
160
|
-
actions: 'setAddress',
|
|
161
|
-
internal: false,
|
|
162
|
-
},
|
|
163
|
-
SET_AMOUNT: {
|
|
164
|
-
target: 'debouncing',
|
|
165
|
-
actions: 'setAmount',
|
|
166
|
-
internal: false,
|
|
167
|
-
},
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
actions: {
|
|
172
|
-
setInitData: assign((context, event) => {
|
|
173
|
-
const { withdrawRule, processing } = event.data
|
|
174
|
-
const { paymentDetail } = context
|
|
175
|
-
const selectedCrypto = paymentDetail.find((item) => item.transferType === 'withdraw' && item.category === 'crypto')
|
|
176
|
-
const networks = (selectedCrypto?.networkName || []).map((value, i) => {
|
|
177
|
-
return {
|
|
178
|
-
label: selectedCrypto.networkOptional?.[i],
|
|
179
|
-
value,
|
|
180
|
-
icon: value,
|
|
181
|
-
}
|
|
182
|
-
})
|
|
183
|
-
|
|
184
|
-
return {
|
|
185
|
-
withdrawRule,
|
|
186
|
-
selectedCrypto,
|
|
187
|
-
networks,
|
|
188
|
-
selectedNetwork: networks[0],
|
|
189
|
-
processing,
|
|
190
|
-
}
|
|
191
|
-
}),
|
|
192
|
-
setNetwork: assign((context, event) => {
|
|
193
|
-
return {
|
|
194
|
-
selectedNetwork: event.data,
|
|
195
|
-
}
|
|
196
|
-
}),
|
|
197
|
-
setAddress: assign((context, event) => {
|
|
198
|
-
return {
|
|
199
|
-
address: event.data,
|
|
200
|
-
}
|
|
201
|
-
}),
|
|
202
|
-
setAmount: assign((context, event) => {
|
|
203
|
-
return {
|
|
204
|
-
selectedAmount: event.data,
|
|
205
|
-
}
|
|
206
|
-
}),
|
|
207
|
-
setCalculation: assign((context, event) => {
|
|
208
|
-
// V2接口轉換中回傳的資料結構不同
|
|
209
|
-
const { data } = event.data
|
|
210
|
-
if (data) {
|
|
211
|
-
return {
|
|
212
|
-
calculation: data,
|
|
213
|
-
}
|
|
214
|
-
} else {
|
|
215
|
-
return {
|
|
216
|
-
calculation: event.data,
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}),
|
|
220
|
-
resetCharge: assign((context, event) => {
|
|
221
|
-
return {
|
|
222
|
-
charge: null,
|
|
223
|
-
}
|
|
224
|
-
}),
|
|
225
|
-
setTransaction: assign((context, event) => {
|
|
226
|
-
const { realAmount } = event.data
|
|
227
|
-
return {
|
|
228
|
-
realAmount,
|
|
229
|
-
}
|
|
230
|
-
}),
|
|
231
|
-
setOtp: assign((context, event) => {
|
|
232
|
-
const { requestId, status, target, ttl } = event.data
|
|
233
|
-
return {
|
|
234
|
-
requestId,
|
|
235
|
-
status,
|
|
236
|
-
target,
|
|
237
|
-
ttl,
|
|
238
|
-
}
|
|
239
|
-
}),
|
|
240
|
-
decreaseTtl: assign((context, evnet) => {
|
|
241
|
-
const second = context.ttl
|
|
242
|
-
return {
|
|
243
|
-
ttl: Math.max(second - 1, 0),
|
|
244
|
-
}
|
|
245
|
-
}),
|
|
246
|
-
setVerificationData: assign((context, event) => {
|
|
247
|
-
const { requestId, ttl, target } = event.data
|
|
248
|
-
return {
|
|
249
|
-
requestId,
|
|
250
|
-
ttl,
|
|
251
|
-
target,
|
|
252
|
-
}
|
|
253
|
-
}),
|
|
254
|
-
setAttachmentType: assign((context, event) => {
|
|
255
|
-
return {
|
|
256
|
-
attachmentType: event.data,
|
|
257
|
-
}
|
|
258
|
-
}),
|
|
259
|
-
setProcessing: assign((context, event) => {
|
|
260
|
-
return {
|
|
261
|
-
processing: event.data,
|
|
262
|
-
}
|
|
263
|
-
}),
|
|
264
|
-
},
|
|
265
|
-
guards: {
|
|
266
|
-
isProcessing: (context, event) => {
|
|
267
|
-
return context.processing
|
|
268
|
-
},
|
|
269
|
-
isCalculable: (context, event) => {
|
|
270
|
-
const { withdrawRule, selectedCrypto, selectedNetwork, selectedAmount } = context
|
|
271
|
-
const maximum = Math.min(withdrawRule.balance, selectedCrypto.maximum)
|
|
272
|
-
return selectedNetwork && selectedAmount && selectedCrypto.minimum <= selectedAmount && selectedAmount <= maximum
|
|
273
|
-
},
|
|
274
|
-
isOtpRequired: (context, event) => {
|
|
275
|
-
return event.data?.status === 'otp-verifying'
|
|
276
|
-
},
|
|
277
|
-
},
|
|
278
|
-
services: {
|
|
279
|
-
fetchInitData: async (context, event) => {
|
|
280
|
-
const [withdrawRule, orders] = await Promise.all([
|
|
281
|
-
request.send(payment.getDoubleWalletWithdrawRule({ walletType: 'CASH' })),
|
|
282
|
-
request.send(payment.getPendingOrder({ transferType: 'WITHDRAW' })),
|
|
283
|
-
])
|
|
284
|
-
|
|
285
|
-
return {
|
|
286
|
-
withdrawRule,
|
|
287
|
-
processing: orders[0],
|
|
288
|
-
}
|
|
289
|
-
},
|
|
290
|
-
fetchWithdrawRule: async (context, event) => {
|
|
291
|
-
return await request.send(payment.getDoubleWalletWithdrawRule({ walletType: 'CASH' }))
|
|
292
|
-
},
|
|
293
|
-
submitWithdraw: async (context, event) => {
|
|
294
|
-
const { selectedCrypto, selectedNetwork, address, selectedAmount } = context
|
|
295
|
-
return await request.send(
|
|
296
|
-
api.submitWithdrawTransactionCrypto({
|
|
297
|
-
method: selectedCrypto.method,
|
|
298
|
-
amount: selectedAmount,
|
|
299
|
-
cryptoCurrency: selectedCrypto.channel,
|
|
300
|
-
cryptoNetwork: selectedNetwork.value,
|
|
301
|
-
targetAddress: address,
|
|
302
|
-
})
|
|
303
|
-
)
|
|
304
|
-
},
|
|
305
|
-
fetchCalculation: async (context, event) => {
|
|
306
|
-
const { selectedCrypto, selectedNetwork, selectedAmount } = context
|
|
307
|
-
const method = selectedCrypto.method
|
|
308
|
-
return await request.send(
|
|
309
|
-
api.getWithdrawExpectedResult({
|
|
310
|
-
method,
|
|
311
|
-
amount: selectedAmount,
|
|
312
|
-
cryptoNetwork: selectedNetwork.value,
|
|
313
|
-
})
|
|
314
|
-
)
|
|
315
|
-
},
|
|
316
|
-
resetOtp: async (context, event) => {
|
|
317
|
-
const { requestId, target } = context
|
|
318
|
-
return await request.send(user.otpReset({ requestId, target }))
|
|
319
|
-
},
|
|
320
|
-
acknowledge: async (context, event) => {
|
|
321
|
-
const { requestId, target } = context
|
|
322
|
-
const code = event.data
|
|
323
|
-
return await request.send(user.otpAcknowledge({ requestId, target, code }))
|
|
324
|
-
},
|
|
325
|
-
},
|
|
326
|
-
}
|
|
327
|
-
)
|
|
328
|
-
}
|
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
import { assign, createMachine } from 'xstate'
|
|
2
|
-
import findLastIndex from 'lodash/findLastIndex.js'
|
|
3
|
-
import payment from '../../api/payment.js'
|
|
4
|
-
import user from '../../api/user.js'
|
|
5
|
-
|
|
6
|
-
export default function (request) {
|
|
7
|
-
const { appSecret } = request.config
|
|
8
|
-
return createMachine(
|
|
9
|
-
{
|
|
10
|
-
id: 'withdraw_krway',
|
|
11
|
-
predictableActionArguments: true,
|
|
12
|
-
initial: 'loading',
|
|
13
|
-
context: {
|
|
14
|
-
userInfo: {},
|
|
15
|
-
paymentDetail: {},
|
|
16
|
-
minimum: 0,
|
|
17
|
-
maximum: 0,
|
|
18
|
-
options: [],
|
|
19
|
-
amount: 0,
|
|
20
|
-
bankInfo: [],
|
|
21
|
-
bank: null,
|
|
22
|
-
enableWithdraw: false,
|
|
23
|
-
applyId: '',
|
|
24
|
-
balance: 0,
|
|
25
|
-
realAmount: 0,
|
|
26
|
-
charge: 0,
|
|
27
|
-
withdrawCheck: null,
|
|
28
|
-
},
|
|
29
|
-
states: {
|
|
30
|
-
loading: {
|
|
31
|
-
invoke: {
|
|
32
|
-
src: 'fetchPaymentDetail',
|
|
33
|
-
onDone: {
|
|
34
|
-
target: 'fetching',
|
|
35
|
-
actions: 'setPaymentData',
|
|
36
|
-
},
|
|
37
|
-
onError: {
|
|
38
|
-
target: 'fail',
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
fetching: {
|
|
43
|
-
invoke: {
|
|
44
|
-
src: 'fetchWithdrawRules',
|
|
45
|
-
onDone: {
|
|
46
|
-
target: 'checking',
|
|
47
|
-
actions: 'updateWithdrawCondition',
|
|
48
|
-
},
|
|
49
|
-
onError: {
|
|
50
|
-
target: 'fail',
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
checking: {
|
|
55
|
-
always: [{ target: 'inProcessing', cond: 'haveProcessing' }, { target: 'withdrawCheck' }],
|
|
56
|
-
},
|
|
57
|
-
withdrawCheck: {
|
|
58
|
-
invoke: {
|
|
59
|
-
src: 'withdrawCheck',
|
|
60
|
-
onDone: [
|
|
61
|
-
{
|
|
62
|
-
target: 'checkingWithdrawStatus',
|
|
63
|
-
actions: assign((context, event) => {
|
|
64
|
-
return {
|
|
65
|
-
withdrawCheck: event.data,
|
|
66
|
-
}
|
|
67
|
-
}),
|
|
68
|
-
},
|
|
69
|
-
],
|
|
70
|
-
onError: {
|
|
71
|
-
target: '#withdraw_krway.fail',
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
checkingWithdrawStatus: {
|
|
76
|
-
always: [
|
|
77
|
-
// 提款最低存款金額
|
|
78
|
-
{ target: 'notWithdrawMinDepositAmount', cond: 'isNotWithdrawMinDepositAmount' },
|
|
79
|
-
// 提款冷卻時間
|
|
80
|
-
{ target: 'passWithdrawCooldownTime', cond: 'isPassWithdrawCooldownTime' },
|
|
81
|
-
// 提款服務時間
|
|
82
|
-
{ target: 'withdrawServiceTime', cond: 'isNotWIthdrawServiceTime' },
|
|
83
|
-
{ target: 'notWithdrawable', cond: 'isNotWithdrawable' },
|
|
84
|
-
{ target: 'withdrawable' },
|
|
85
|
-
],
|
|
86
|
-
},
|
|
87
|
-
notWithdrawMinDepositAmount: {},
|
|
88
|
-
passWithdrawCooldownTime: {},
|
|
89
|
-
inProcessing: {},
|
|
90
|
-
withdrawServiceTime: {},
|
|
91
|
-
notWithdrawable: {},
|
|
92
|
-
withdrawable: {
|
|
93
|
-
on: {
|
|
94
|
-
ADD_AMOUNT: {
|
|
95
|
-
actions: 'addAmount',
|
|
96
|
-
},
|
|
97
|
-
SET_AMOUNT: {
|
|
98
|
-
actions: 'setAmount',
|
|
99
|
-
},
|
|
100
|
-
CLEAR_AMOUNT: {
|
|
101
|
-
actions: 'clearAmount',
|
|
102
|
-
},
|
|
103
|
-
SUBMIT: {
|
|
104
|
-
target: 'submitting',
|
|
105
|
-
cond: 'isSubmittable',
|
|
106
|
-
},
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
submitting: {
|
|
110
|
-
invoke: {
|
|
111
|
-
src: 'submitWithdraw',
|
|
112
|
-
onDone: {
|
|
113
|
-
target: 'submitted',
|
|
114
|
-
actions: 'setResult',
|
|
115
|
-
},
|
|
116
|
-
onError: {
|
|
117
|
-
target: 'withdrawable',
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
submitted: {
|
|
122
|
-
invoke: {
|
|
123
|
-
src: 'fetchPaymentDetail',
|
|
124
|
-
onDone: {
|
|
125
|
-
target: 'inProcessing',
|
|
126
|
-
actions: 'setPaymentData',
|
|
127
|
-
},
|
|
128
|
-
onError: {
|
|
129
|
-
target: 'fail',
|
|
130
|
-
},
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
fail: {},
|
|
134
|
-
},
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
actions: {
|
|
138
|
-
setPaymentData: assign((context, event) => {
|
|
139
|
-
const { paymentDetail, bankInfo } = event.data
|
|
140
|
-
const { minimum, maximum, optional } = paymentDetail?.[0] || {}
|
|
141
|
-
return { paymentDetail, bank: bankInfo[0], minimum, maximum, options: optional }
|
|
142
|
-
}),
|
|
143
|
-
updateWithdrawCondition: assign((context, event) => {
|
|
144
|
-
const { enableWithdraw, balance } = event.data
|
|
145
|
-
return {
|
|
146
|
-
balance,
|
|
147
|
-
enableWithdraw,
|
|
148
|
-
}
|
|
149
|
-
}),
|
|
150
|
-
addAmount: assign((context, event) => {
|
|
151
|
-
return {
|
|
152
|
-
amount: parseFloat(`${context.amount || 0}`) + parseFloat(`${event.data}`),
|
|
153
|
-
}
|
|
154
|
-
}),
|
|
155
|
-
setAmount: assign((context, event) => {
|
|
156
|
-
return { amount: parseFloat(`${event.data}`) }
|
|
157
|
-
}),
|
|
158
|
-
clearAmount: assign((context, event) => {
|
|
159
|
-
return { amount: null }
|
|
160
|
-
}),
|
|
161
|
-
setResult: assign((context, event) => {
|
|
162
|
-
const { applyId, balance, realAmount, charge } = event.data
|
|
163
|
-
return { applyId, balance, realAmount, charge }
|
|
164
|
-
}),
|
|
165
|
-
},
|
|
166
|
-
guards: {
|
|
167
|
-
haveProcessing: (context, event) => {
|
|
168
|
-
return (context.paymentDetail?.[0]?.processing || []).length > 0
|
|
169
|
-
},
|
|
170
|
-
isSubmittable: (context, event) => {
|
|
171
|
-
const { amount } = context
|
|
172
|
-
return parseFloat(`${amount}`) > 0
|
|
173
|
-
},
|
|
174
|
-
isNotWithdrawable: (context, event) => {
|
|
175
|
-
const { balance, enableWithdraw, paymentDetail } = context
|
|
176
|
-
const minWithdrawAmount = paymentDetail[0]?.minimum || 0
|
|
177
|
-
return !enableWithdraw || balance < minWithdrawAmount
|
|
178
|
-
},
|
|
179
|
-
isNotWithdrawMinDepositAmount: (context, event) => {
|
|
180
|
-
const { withdrawCheck } = context
|
|
181
|
-
return !withdrawCheck?.passDepositeLimit
|
|
182
|
-
},
|
|
183
|
-
isPassWithdrawCooldownTime: (context, event) => {
|
|
184
|
-
const { withdrawCheck } = context
|
|
185
|
-
return !withdrawCheck?.passWithdrawCooldownTime
|
|
186
|
-
},
|
|
187
|
-
isNotWIthdrawServiceTime: (context, event) => {
|
|
188
|
-
const { withdrawCheck } = context
|
|
189
|
-
return !withdrawCheck?.withdrawInServiceTime
|
|
190
|
-
},
|
|
191
|
-
},
|
|
192
|
-
services: {
|
|
193
|
-
fetchPaymentDetail: async (context, event) => {
|
|
194
|
-
const [paymentDetail = [], { bankInfo }] = await Promise.all([
|
|
195
|
-
request.send(payment.getPaymentDetail({ transferType: 'WITHDRAW' })),
|
|
196
|
-
request.send(payment.getPaymentInfo()),
|
|
197
|
-
])
|
|
198
|
-
return { paymentDetail, bankInfo }
|
|
199
|
-
},
|
|
200
|
-
fetchWithdrawRules: async (context, event) => {
|
|
201
|
-
return await request.send(payment.getDoubleWalletWithdrawRule({ walletType: 'CASH' }))
|
|
202
|
-
},
|
|
203
|
-
submitWithdraw: async (context, event) => {
|
|
204
|
-
const { paymentDetail, amount, bank } = context
|
|
205
|
-
const { method } = paymentDetail[0]
|
|
206
|
-
return await request.send(
|
|
207
|
-
payment.submitWithdrawTransactionVN({
|
|
208
|
-
method,
|
|
209
|
-
amount,
|
|
210
|
-
applyerBankCode: bank.bankCode,
|
|
211
|
-
applyerAccountNumber: bank.accountNumber,
|
|
212
|
-
branch: bank.branch,
|
|
213
|
-
holderName: bank.holderName,
|
|
214
|
-
})
|
|
215
|
-
)
|
|
216
|
-
},
|
|
217
|
-
withdrawCheck: async (context, event) => {
|
|
218
|
-
return await request.send(payment.withdrawCheck())
|
|
219
|
-
},
|
|
220
|
-
},
|
|
221
|
-
}
|
|
222
|
-
)
|
|
223
|
-
}
|