@jetthai/cuora 1.1.488 → 2.0.0-beta.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/.husky/pre-commit +3 -1
- package/BREAKING_CHANGES.md +9 -0
- package/CHANGELOG.md +3 -316
- package/README.md +15 -299
- package/package.json +5 -5
- package/resetGitBranch.sh +101 -0
- package/src/api/account.js +1 -0
- package/src/api/activity.js +39 -24
- package/src/api/auth.js +36 -5
- package/src/api/common.js +3 -5
- package/src/api/game.js +10 -0
- package/src/api/payment.js +55 -17
- package/src/api/user.js +16 -10
- package/src/index.js +2 -2
- package/src/lib/fingerprint_v3_11_12.js +11433 -0
- package/src/machine/activity/activity.js +213 -0
- package/src/machine/activity/activity_cash.js +36 -84
- 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 +8 -0
- package/src/machine/activity/diamond_shop_activity_fc.js +197 -0
- package/src/machine/activity/diamond_shop_activity_vn.js +179 -0
- package/src/machine/activity/fafafa_activity.js +11 -0
- package/src/machine/activity/friend_invite_friends_activity.js +7 -8
- package/src/machine/activity/index.js +12 -0
- package/src/machine/activity/instant_rebate_activity.js +1 -0
- package/src/machine/activity/invite_friends_activity.js +115 -0
- package/src/machine/activity/jackpot.js +1 -0
- package/src/machine/activity/mini_game_activity.js +69 -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 +155 -0
- package/src/machine/activity/roulette_activity_v2.js +1 -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 +112 -149
- package/src/machine/auth_otp_v2.js +178 -0
- package/src/machine/auth_otp_v3.js +22 -64
- package/src/machine/bank_binding.js +3 -2
- package/src/machine/bank_binding_amb.js +146 -0
- package/src/machine/bonus.js +76 -0
- package/src/machine/common.js +98 -14
- package/src/machine/deposit/amb.js +93 -0
- package/src/machine/deposit/crypto_bank.js +340 -0
- package/src/machine/deposit/crypto_bank_cash.js +35 -20
- package/src/machine/deposit/crypto_qrcode.js +158 -0
- package/src/machine/deposit/crypto_qrcode_cash.js +64 -26
- package/src/machine/deposit/crypto_way.js +253 -0
- package/src/machine/deposit/crypto_way_cash.js +37 -48
- package/src/machine/deposit/deposit_fc.js +272 -0
- package/src/machine/deposit/direct.js +311 -0
- package/src/machine/deposit/direct_cash.js +10 -8
- package/src/machine/deposit/float.js +375 -0
- package/src/machine/deposit/index.js +28 -0
- package/src/machine/deposit/krway.js +152 -0
- package/src/machine/deposit/loadcard_cash.js +32 -14
- package/src/machine/deposit/loadcard_vn.js +352 -0
- package/src/machine/deposit/manual_cash.js +11 -8
- package/src/machine/deposit/manual_vn.js +459 -0
- package/src/machine/deposit/qrcode_cash.js +32 -15
- package/src/machine/deposit/qrcode_v2.js +339 -0
- package/src/machine/deposit/usdt.js +163 -0
- package/src/machine/deposit/usdt_cash.js +15 -1
- package/src/machine/deposit/virtual_bank_cash.js +12 -13
- package/src/machine/deposit/virtual_bank_vn.js +270 -0
- package/src/machine/deposit/vpay.js +374 -0
- package/src/machine/error.js +1 -7
- package/src/machine/game_betslip.js +1 -0
- package/src/machine/game_favorite_v2.js +1 -0
- package/src/machine/game_hot_new.js +80 -0
- package/src/machine/game_info.js +13 -1
- package/src/machine/game_replay.js +47 -0
- package/src/machine/game_search_cash.js +1 -0
- package/src/machine/game_search_v2.js +402 -0
- package/src/machine/game_v2_1.js +126 -39
- package/src/machine/honor_board.js +133 -0
- package/src/machine/honor_board_cash.js +28 -22
- package/src/machine/inbox.js +105 -43
- package/src/machine/index.js +32 -0
- package/src/machine/leaderboard.js +12 -8
- package/src/machine/merge.js +58 -0
- package/src/machine/navbar.js +3 -1
- package/src/machine/payment_data.js +87 -0
- package/src/machine/promotions.js +163 -0
- package/src/machine/ranking.js +30 -45
- package/src/machine/reward.js +256 -0
- package/src/machine/reward_cash.js +42 -2
- package/src/machine/reward_fc.js +99 -0
- package/src/machine/roulette_v2.js +11 -14
- package/src/machine/setting.js +1 -0
- package/src/machine/side.js +160 -0
- package/src/machine/side_cash.js +3 -3
- package/src/machine/side_v2.js +223 -0
- package/src/machine/user_info.js +1 -0
- package/src/machine/user_photo.js +1 -0
- package/src/machine/user_reset_password.js +14 -0
- package/src/machine/user_sign_up.js +61 -46
- package/src/machine/vip_table.js +58 -0
- package/src/machine/websocket.js +349 -374
- package/src/machine/welcome.js +111 -0
- package/src/machine/withdraw/index.js +6 -0
- package/src/machine/withdraw/withdraw_crypto_cash.js +328 -0
- package/src/machine/withdraw/withdraw_krway.js +223 -0
- package/src/machine/withdraw/withdraw_manual.js +541 -0
- package/src/machine/withdraw/withdraw_manual_cash.js +39 -59
- package/src/request/config.js +0 -2
- package/src/request/request.js +60 -124
- package/src/util/constant.js +2 -6
- package/src/util/deviceToken.js +60 -0
- package/src/util/index.js +4 -2
- package/src/util/math.js +4 -0
- 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 +155 -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 +133 -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 +603 -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
- package/.claude/commands/sync-ai-prompts.md +0 -93
- package/.claude/settings.local.json +0 -23
- package/.github/copilot-instructions.md +0 -448
- package/.husky/post-checkout +0 -32
- package/.husky/pre-push +0 -36
- package/AGENTS.md +0 -448
- package/AI_PROMPT_SOURCE.md +0 -446
- package/CLAUDE.md +0 -448
- package/GEMINI.md +0 -448
- package/docs/kibana/crypto-way-deposit-amount-bug-analysis.md +0 -1003
- package/docs/kibana/play-providerId-error.md +0 -202
- package/docs/kibana/play-selectedWalletType.md +0 -1
- package/docs/kibana/play-selectedWalletType_2.md +0 -1
- package/docs/kibana/play-selectedWalletType_analysis.md +0 -565
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/branch-transfer.md +0 -14
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/cash-module-preparation.json +0 -40
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/cash-module-verification.md +0 -41
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/implementation-ledger.md +0 -87
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/module-report.md +0 -73
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/plan.md +0 -309
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/test-cases.md +0 -245
- package/docs/my-claude/feat-sharon-JT-1791180540-onesignal/transfer.md +0 -9
- package/scripts/auto-version.js +0 -68
- package/scripts/auto-version.sh +0 -33
- package/scripts/branch-auto-npm-publish.js +0 -29
- package/scripts/check-version.sh +0 -36
- package/scripts/clean-tags.sh +0 -84
- package/src/util/amount.js +0 -8
- package/src/util/err998SentryExtra.js +0 -26
- package/src/util/paramStore.js +0 -139
- package/src/util/socketPolicy.js +0 -57
- package/test/auth_otp_v3.test.js +0 -323
- package/tests/websocket.test.mjs +0 -779
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { assign, createMachine } from 'xstate'
|
|
2
|
+
import payment from '../api/payment.js'
|
|
3
|
+
import user from '../api/user.js'
|
|
4
|
+
import storage from '../util/storage.js'
|
|
5
|
+
|
|
6
|
+
export default function (request) {
|
|
7
|
+
return createMachine(
|
|
8
|
+
{
|
|
9
|
+
id: 'welcome',
|
|
10
|
+
predictableActionArguments: true,
|
|
11
|
+
initial: 'loading',
|
|
12
|
+
context: {
|
|
13
|
+
userInfo: null,
|
|
14
|
+
bonus: null,
|
|
15
|
+
gender: null,
|
|
16
|
+
},
|
|
17
|
+
states: {
|
|
18
|
+
loading: {
|
|
19
|
+
invoke: {
|
|
20
|
+
src: 'fetchUserInfo',
|
|
21
|
+
onDone: {
|
|
22
|
+
target: 'checking',
|
|
23
|
+
actions: 'setUserInfo',
|
|
24
|
+
},
|
|
25
|
+
onError: {
|
|
26
|
+
target: 'checking',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
checking: {
|
|
31
|
+
always: [{ target: 'firstLogin', cond: 'isFirstLogin' }, { target: 'completed' }],
|
|
32
|
+
},
|
|
33
|
+
firstLogin: {
|
|
34
|
+
initial: 'input',
|
|
35
|
+
states: {
|
|
36
|
+
input: {
|
|
37
|
+
on: {
|
|
38
|
+
SET_BONUS: {
|
|
39
|
+
actions: 'setBonus',
|
|
40
|
+
},
|
|
41
|
+
SET_GENDER: {
|
|
42
|
+
actions: 'setGender',
|
|
43
|
+
},
|
|
44
|
+
SEND_INFO: {
|
|
45
|
+
target: 'submitting',
|
|
46
|
+
cond: 'isFilled',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
submitting: {
|
|
51
|
+
invoke: {
|
|
52
|
+
src: 'updatingInfo',
|
|
53
|
+
onDone: {
|
|
54
|
+
target: '#welcome.completed',
|
|
55
|
+
},
|
|
56
|
+
onError: {
|
|
57
|
+
target: '#welcome.completed',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
exit: 'setInfo',
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
completed: {},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
guards: {
|
|
69
|
+
isFirstLogin: (context, event) => {
|
|
70
|
+
const { bank_account, bank_setting_status, topup, verification_status, uid } = context.userInfo || {}
|
|
71
|
+
// const hasBankAccount = bank_account || bank_setting_status === 1 // sabai
|
|
72
|
+
const isComplete = topup === 1 || verification_status === 1
|
|
73
|
+
const isSent = storage.get(`welcome_${uid}`)
|
|
74
|
+
return !(isSent || isComplete)
|
|
75
|
+
},
|
|
76
|
+
isFilled: (context, event) => {
|
|
77
|
+
const { bonus, gender } = context
|
|
78
|
+
return bonus !== null && gender !== null
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
actions: {
|
|
82
|
+
setUserInfo: assign((context, event) => {
|
|
83
|
+
return {
|
|
84
|
+
userInfo: event.data,
|
|
85
|
+
}
|
|
86
|
+
}),
|
|
87
|
+
setInfo: (context, event) => {
|
|
88
|
+
storage.set(`welcome_${context.userInfo.uid}`, 'done', {
|
|
89
|
+
path: '/',
|
|
90
|
+
maxAge: 60 * 60 * 24 * 365,
|
|
91
|
+
})
|
|
92
|
+
},
|
|
93
|
+
setBonus: assign((context, event) => {
|
|
94
|
+
return { bonus: event.data }
|
|
95
|
+
}),
|
|
96
|
+
setGender: assign((context, event) => {
|
|
97
|
+
return { gender: event.data }
|
|
98
|
+
}),
|
|
99
|
+
},
|
|
100
|
+
services: {
|
|
101
|
+
fetchUserInfo: async (context, event) => {
|
|
102
|
+
return await request.send(user.getUserInfo())
|
|
103
|
+
},
|
|
104
|
+
updatingInfo: async (context, event) => {
|
|
105
|
+
const { bonus, gender } = context
|
|
106
|
+
await Promise.all([request.send(payment.setBonusSetting({ bonus })), request.send(user.updateUserInfo({ gender }))])
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
}
|
|
110
|
+
)
|
|
111
|
+
}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
import withdraw_manual from './withdraw_manual.js'
|
|
2
|
+
import withdraw_krway from './withdraw_krway.js'
|
|
3
|
+
import withdraw_crypto_cash from './withdraw_crypto_cash.js'
|
|
1
4
|
import withdraw_manual_cash from './withdraw_manual_cash.js'
|
|
2
5
|
|
|
3
6
|
export default {
|
|
7
|
+
withdraw_manual,
|
|
8
|
+
withdraw_krway,
|
|
9
|
+
withdraw_crypto_cash,
|
|
4
10
|
withdraw_manual_cash,
|
|
5
11
|
}
|
|
@@ -0,0 +1,328 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,223 @@
|
|
|
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
|
+
}
|