@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,69 +0,0 @@
|
|
|
1
|
-
import { assign, createMachine } from 'xstate'
|
|
2
|
-
import api from '../../api/activity.js'
|
|
3
|
-
|
|
4
|
-
export default function (request) {
|
|
5
|
-
const { appSecret } = request.config
|
|
6
|
-
return createMachine(
|
|
7
|
-
{
|
|
8
|
-
id: 'mini_game_activity',
|
|
9
|
-
predictableActionArguments: true,
|
|
10
|
-
context: {
|
|
11
|
-
activityNo: null,
|
|
12
|
-
activityDetail: null,
|
|
13
|
-
},
|
|
14
|
-
initial: 'idle',
|
|
15
|
-
states: {
|
|
16
|
-
idle: {
|
|
17
|
-
on: {
|
|
18
|
-
SET_ACTIVITY_NO: {
|
|
19
|
-
target: 'loading',
|
|
20
|
-
actions: 'setActivityNo',
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
loading: {
|
|
25
|
-
invoke: {
|
|
26
|
-
src: 'fetchActivityDetail',
|
|
27
|
-
onDone: {
|
|
28
|
-
target: 'loaded',
|
|
29
|
-
actions: 'setActivityDetail',
|
|
30
|
-
},
|
|
31
|
-
onError: {
|
|
32
|
-
target: 'idle',
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
loaded: {},
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
actions: {
|
|
41
|
-
setActivityNo: assign((context, event) => {
|
|
42
|
-
return {
|
|
43
|
-
activityNo: event.data,
|
|
44
|
-
}
|
|
45
|
-
}),
|
|
46
|
-
setDiamondShopActivities: assign((context, event) => {
|
|
47
|
-
const rankActivities = event.data.filter((item) => item.activityType === 92)
|
|
48
|
-
return {
|
|
49
|
-
rankActivities,
|
|
50
|
-
activityNo: rankActivities?.[0]?.activityNo,
|
|
51
|
-
}
|
|
52
|
-
}),
|
|
53
|
-
setActivityDetail: assign((context, event) => {
|
|
54
|
-
return {
|
|
55
|
-
activityDetail: event.data,
|
|
56
|
-
}
|
|
57
|
-
}),
|
|
58
|
-
},
|
|
59
|
-
guards: {},
|
|
60
|
-
services: {
|
|
61
|
-
fetchActivityDetail: async (context, event) => {
|
|
62
|
-
const { activityNo } = context
|
|
63
|
-
const { data } = await request.send(api.getActivityDetail({ activityNo, appSecret }))
|
|
64
|
-
return data
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
}
|
|
68
|
-
)
|
|
69
|
-
}
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { assign, createMachine } from 'xstate'
|
|
2
|
-
import api from '../../api/activity.js'
|
|
3
|
-
import isEqual from 'lodash/isEqual.js'
|
|
4
|
-
|
|
5
|
-
// const isEqual = require('lodash/isEqual')
|
|
6
|
-
|
|
7
|
-
export default function (request) {
|
|
8
|
-
const { appSecret } = request.config
|
|
9
|
-
return createMachine(
|
|
10
|
-
{
|
|
11
|
-
id: 'return_bonus_activity',
|
|
12
|
-
predictableActionArguments: true,
|
|
13
|
-
context: {
|
|
14
|
-
activityNo: null,
|
|
15
|
-
activityDetail: null,
|
|
16
|
-
rewardList: [],
|
|
17
|
-
callback: () => {},
|
|
18
|
-
},
|
|
19
|
-
initial: 'idle',
|
|
20
|
-
states: {
|
|
21
|
-
idle: {
|
|
22
|
-
always: [{ target: 'loading', cond: 'hasActivityNo' }],
|
|
23
|
-
on: {
|
|
24
|
-
SET_REWARD_LIST: {
|
|
25
|
-
actions: 'setRewardList',
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
loading: {
|
|
30
|
-
invoke: {
|
|
31
|
-
src: 'fetchActivityDetail',
|
|
32
|
-
onDone: {
|
|
33
|
-
target: 'loaded',
|
|
34
|
-
actions: 'setActivityDetail',
|
|
35
|
-
},
|
|
36
|
-
onError: {
|
|
37
|
-
target: 'idle',
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
on: {
|
|
41
|
-
SET_REWARD_LIST: {
|
|
42
|
-
actions: 'setRewardList',
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
loaded: {
|
|
47
|
-
always: [{ target: 'receivable', cond: 'isReceivable' }, { target: 'notReceivableYet', cond: 'isNotReceivableYet' }, { target: 'empty' }],
|
|
48
|
-
},
|
|
49
|
-
receivable: {
|
|
50
|
-
on: {
|
|
51
|
-
RECEIVE_REWARD: {
|
|
52
|
-
target: 'receiving',
|
|
53
|
-
actions: 'setCallback',
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
notReceivableYet: {
|
|
58
|
-
after: {
|
|
59
|
-
20000: {
|
|
60
|
-
target: 'loading',
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
empty: {
|
|
65
|
-
after: {
|
|
66
|
-
20000: {
|
|
67
|
-
target: 'loading',
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
receiving: {
|
|
72
|
-
invoke: {
|
|
73
|
-
src: 'receiveReward',
|
|
74
|
-
onDone: {
|
|
75
|
-
target: 'loading',
|
|
76
|
-
actions: 'doCallback',
|
|
77
|
-
},
|
|
78
|
-
onError: {
|
|
79
|
-
target: 'loading',
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
on: {
|
|
85
|
-
SET_ACTIVITY_NO: {
|
|
86
|
-
target: '.idle',
|
|
87
|
-
actions: 'setActivityNo',
|
|
88
|
-
cond: 'isActivityChanged',
|
|
89
|
-
},
|
|
90
|
-
SET_REWARD_LIST: {
|
|
91
|
-
target: '.loaded',
|
|
92
|
-
actions: 'setRewardList',
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
actions: {
|
|
98
|
-
setActivityNo: assign((context, event) => {
|
|
99
|
-
return {
|
|
100
|
-
activityNo: event.data,
|
|
101
|
-
}
|
|
102
|
-
}),
|
|
103
|
-
setActivityDetail: assign((context, event) => {
|
|
104
|
-
return {
|
|
105
|
-
activityDetail: event.data,
|
|
106
|
-
}
|
|
107
|
-
}),
|
|
108
|
-
setRewardList: assign((context, event) => {
|
|
109
|
-
const source = Array.isArray(event.data) ? event.data : []
|
|
110
|
-
const rewardList = source.filter((item) => item.activityType === 4 && item.receiveStatus === 0)
|
|
111
|
-
return { rewardList }
|
|
112
|
-
}),
|
|
113
|
-
setCallback: assign((context, event) => {
|
|
114
|
-
return {
|
|
115
|
-
callback: event.data?.callback || (() => {}),
|
|
116
|
-
}
|
|
117
|
-
}),
|
|
118
|
-
doCallback: (context, event) => {
|
|
119
|
-
context.callback()
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
guards: {
|
|
123
|
-
isActivityChanged: (context, event) => {
|
|
124
|
-
return !isEqual(context.activityNo, event.data)
|
|
125
|
-
},
|
|
126
|
-
hasActivityNo: (context, event) => {
|
|
127
|
-
return context.activityNo
|
|
128
|
-
},
|
|
129
|
-
isReceivable: (context, event) => {
|
|
130
|
-
return context.rewardList?.length > 0
|
|
131
|
-
},
|
|
132
|
-
isNotReceivableYet: (context, event) => {
|
|
133
|
-
return !context.rewardList?.length && context.activityDetail?.rebateAmount > 0
|
|
134
|
-
},
|
|
135
|
-
},
|
|
136
|
-
services: {
|
|
137
|
-
fetchActivityDetail: async (context, event) => {
|
|
138
|
-
const { activityNo } = context
|
|
139
|
-
const { data } = await request.send(api.getActivityDetail({ activityNo, appSecret }))
|
|
140
|
-
return data
|
|
141
|
-
},
|
|
142
|
-
receiveReward: async (context, event) => {
|
|
143
|
-
const { activityNo, receiveNo } = context.rewardList[0]
|
|
144
|
-
const validateReceiveNo = Number(receiveNo) > 0 ? Number(receiveNo) : undefined
|
|
145
|
-
const { data } = await request.send(api.getReward({ activityNo, receiveNo: validateReceiveNo, appSecret }))
|
|
146
|
-
return data
|
|
147
|
-
},
|
|
148
|
-
fetchRewardList: async (context, event) => {
|
|
149
|
-
const { data } = await request.send(api.getRewardList({ appSecret, count: 30 }))
|
|
150
|
-
return data
|
|
151
|
-
},
|
|
152
|
-
},
|
|
153
|
-
}
|
|
154
|
-
)
|
|
155
|
-
}
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import { assign, createMachine } from 'xstate'
|
|
2
|
-
import user from '../api/user.js'
|
|
3
|
-
|
|
4
|
-
export default function (request) {
|
|
5
|
-
return createMachine(
|
|
6
|
-
{
|
|
7
|
-
id: 'auth_otp_v2',
|
|
8
|
-
predictableActionArguments: true,
|
|
9
|
-
initial: 'idle',
|
|
10
|
-
context: {
|
|
11
|
-
strategy: null,
|
|
12
|
-
requestId: null,
|
|
13
|
-
ttl: null,
|
|
14
|
-
target: {},
|
|
15
|
-
acknowledgeTtl: null,
|
|
16
|
-
newPassword: null,
|
|
17
|
-
},
|
|
18
|
-
states: {
|
|
19
|
-
idle: {
|
|
20
|
-
on: {
|
|
21
|
-
SET_OTP_INITIALIZATION: {
|
|
22
|
-
target: 'otp',
|
|
23
|
-
actions: 'setOtpResult',
|
|
24
|
-
},
|
|
25
|
-
SEND_OTP_EMAIL: {
|
|
26
|
-
target: 'otpFetching',
|
|
27
|
-
actions: 'setStrategyEmail',
|
|
28
|
-
},
|
|
29
|
-
SEND_OTP_PHONE: {
|
|
30
|
-
target: 'otpFetching',
|
|
31
|
-
actions: 'setStrategyPhone',
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
otpFetching: {
|
|
36
|
-
invoke: {
|
|
37
|
-
src: 'sendOtp',
|
|
38
|
-
onDone: [
|
|
39
|
-
{
|
|
40
|
-
target: 'acknowledged',
|
|
41
|
-
cond: (context, event) => event.data.status === 'success-verified',
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
target: 'otp',
|
|
45
|
-
actions: 'setOtpResult',
|
|
46
|
-
},
|
|
47
|
-
],
|
|
48
|
-
onError: {
|
|
49
|
-
target: 'idle',
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
otp: {
|
|
54
|
-
after: {
|
|
55
|
-
1000: [
|
|
56
|
-
{
|
|
57
|
-
target: 'otp',
|
|
58
|
-
actions: 'decreaseTtl',
|
|
59
|
-
cond: (context) => context.ttl > 0,
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
target: 'idle',
|
|
63
|
-
},
|
|
64
|
-
],
|
|
65
|
-
},
|
|
66
|
-
on: {
|
|
67
|
-
ACKNOWLEDGE: {
|
|
68
|
-
target: 'acknowledging',
|
|
69
|
-
},
|
|
70
|
-
BACK: {
|
|
71
|
-
target: 'idle',
|
|
72
|
-
},
|
|
73
|
-
RESET_OTP: {
|
|
74
|
-
target: 'otpResetting',
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
otpResetting: {
|
|
79
|
-
invoke: {
|
|
80
|
-
src: 'resetOtp',
|
|
81
|
-
onDone: {
|
|
82
|
-
target: 'otp',
|
|
83
|
-
actions: 'setOtpResult',
|
|
84
|
-
},
|
|
85
|
-
onError: {
|
|
86
|
-
target: 'otp',
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
acknowledging: {
|
|
91
|
-
invoke: {
|
|
92
|
-
src: 'acknowledge',
|
|
93
|
-
onDone: {
|
|
94
|
-
target: 'acknowledged',
|
|
95
|
-
actions: 'setAcknowledgeResult',
|
|
96
|
-
},
|
|
97
|
-
onError: [
|
|
98
|
-
{
|
|
99
|
-
target: 'idle',
|
|
100
|
-
cond: (context, event) => event.data.code === 'ERR_A108',
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
target: 'otp',
|
|
104
|
-
},
|
|
105
|
-
],
|
|
106
|
-
},
|
|
107
|
-
},
|
|
108
|
-
acknowledged: {
|
|
109
|
-
// after: {
|
|
110
|
-
// 1000: [
|
|
111
|
-
// {
|
|
112
|
-
// target: 'acknowledged',
|
|
113
|
-
// actions: 'decreaseAcknowledgeTtl',
|
|
114
|
-
// cond: (context) => context.acknowledgeTtl > 0,
|
|
115
|
-
// },
|
|
116
|
-
// {
|
|
117
|
-
// target: 'idle',
|
|
118
|
-
// },
|
|
119
|
-
// ],
|
|
120
|
-
// },
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
actions: {
|
|
126
|
-
setStrategyPhone: assign((context, event) => {
|
|
127
|
-
return {
|
|
128
|
-
strategy: 'phone',
|
|
129
|
-
}
|
|
130
|
-
}),
|
|
131
|
-
setStrategyEmail: assign((context, event) => {
|
|
132
|
-
return {
|
|
133
|
-
strategy: 'email',
|
|
134
|
-
}
|
|
135
|
-
}),
|
|
136
|
-
setOtpResult: assign((context, event) => {
|
|
137
|
-
const { requestId, ttl, target } = event.data
|
|
138
|
-
return {
|
|
139
|
-
requestId,
|
|
140
|
-
ttl,
|
|
141
|
-
target,
|
|
142
|
-
}
|
|
143
|
-
}),
|
|
144
|
-
decreaseTtl: assign((context, event) => {
|
|
145
|
-
return {
|
|
146
|
-
ttl: Math.max(context.ttl - 1, 0),
|
|
147
|
-
}
|
|
148
|
-
}),
|
|
149
|
-
setAcknowledgeResult: assign((context, event) => {
|
|
150
|
-
const { requestId, ttl, target } = event.data
|
|
151
|
-
return {
|
|
152
|
-
acknowledgeTtl: ttl,
|
|
153
|
-
}
|
|
154
|
-
}),
|
|
155
|
-
decreaseAcknowledgeTtl: assign((context, event) => {
|
|
156
|
-
return {
|
|
157
|
-
acknowledgeTtl: Math.max(context.acknowledgeTtl - 1, 0),
|
|
158
|
-
}
|
|
159
|
-
}),
|
|
160
|
-
},
|
|
161
|
-
services: {
|
|
162
|
-
sendOtp: async (context, event) => {
|
|
163
|
-
const { strategy } = context
|
|
164
|
-
return await request.send(user.verifyV2Initiate({ strategy }))
|
|
165
|
-
},
|
|
166
|
-
resetOtp: async (context, event) => {
|
|
167
|
-
const { requestId, target } = context
|
|
168
|
-
return await request.send(user.otpReset({ requestId, target }))
|
|
169
|
-
},
|
|
170
|
-
acknowledge: async (context, event) => {
|
|
171
|
-
const { requestId, target } = context
|
|
172
|
-
const code = event.data
|
|
173
|
-
return await request.send(user.otpAcknowledge({ requestId, target, code }))
|
|
174
|
-
},
|
|
175
|
-
},
|
|
176
|
-
}
|
|
177
|
-
)
|
|
178
|
-
}
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { assign, createMachine } from 'xstate'
|
|
2
|
-
import payment from '../api/payment.js'
|
|
3
|
-
|
|
4
|
-
export default function (request) {
|
|
5
|
-
const { appSecret } = request.config
|
|
6
|
-
|
|
7
|
-
return createMachine(
|
|
8
|
-
{
|
|
9
|
-
id: 'bank_binding_amb',
|
|
10
|
-
predictableActionArguments: true,
|
|
11
|
-
initial: 'fetching',
|
|
12
|
-
context: {
|
|
13
|
-
hasAnyAccount: false,
|
|
14
|
-
bankList: [],
|
|
15
|
-
bank: null,
|
|
16
|
-
// bonus: 0,
|
|
17
|
-
bankAccount: null,
|
|
18
|
-
firstNameTh: null,
|
|
19
|
-
lastNameTh: null,
|
|
20
|
-
firstNameEn: null,
|
|
21
|
-
lastNameEn: null,
|
|
22
|
-
},
|
|
23
|
-
states: {
|
|
24
|
-
fetching: {
|
|
25
|
-
invoke: {
|
|
26
|
-
src: 'fetchInitData',
|
|
27
|
-
onDone: {
|
|
28
|
-
target: 'idle',
|
|
29
|
-
actions: 'setBanks',
|
|
30
|
-
},
|
|
31
|
-
onError: {
|
|
32
|
-
target: 'idle',
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
idle: {
|
|
37
|
-
on: {
|
|
38
|
-
SET_BANK_CODE: {
|
|
39
|
-
actions: assign((context, event) => {
|
|
40
|
-
return {
|
|
41
|
-
bank: event.data,
|
|
42
|
-
}
|
|
43
|
-
}),
|
|
44
|
-
},
|
|
45
|
-
SET_BANK_ACCOUNT: {
|
|
46
|
-
actions: assign((context, event) => {
|
|
47
|
-
return {
|
|
48
|
-
bankAccount: event.data,
|
|
49
|
-
}
|
|
50
|
-
}),
|
|
51
|
-
},
|
|
52
|
-
SET_FIRST_NAME_TH: {
|
|
53
|
-
actions: assign((context, event) => {
|
|
54
|
-
return {
|
|
55
|
-
firstNameTh: event.data,
|
|
56
|
-
}
|
|
57
|
-
}),
|
|
58
|
-
},
|
|
59
|
-
SET_LAST_NAME_TH: {
|
|
60
|
-
actions: assign((context, event) => {
|
|
61
|
-
return {
|
|
62
|
-
lastNameTh: event.data,
|
|
63
|
-
}
|
|
64
|
-
}),
|
|
65
|
-
},
|
|
66
|
-
SET_FIRST_NAME_EN: {
|
|
67
|
-
actions: assign((context, event) => {
|
|
68
|
-
return {
|
|
69
|
-
firstNameEn: event.data,
|
|
70
|
-
}
|
|
71
|
-
}),
|
|
72
|
-
},
|
|
73
|
-
SET_LAST_NAME_EN: {
|
|
74
|
-
actions: assign((context, event) => {
|
|
75
|
-
return {
|
|
76
|
-
lastNameEn: event.data,
|
|
77
|
-
}
|
|
78
|
-
}),
|
|
79
|
-
},
|
|
80
|
-
BIND_BANK: {
|
|
81
|
-
target: 'binding',
|
|
82
|
-
cond: 'isBindable',
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
binding: {
|
|
87
|
-
invoke: {
|
|
88
|
-
src: 'updatePaymentInfo',
|
|
89
|
-
onDone: {
|
|
90
|
-
target: 'bound',
|
|
91
|
-
},
|
|
92
|
-
onError: {
|
|
93
|
-
target: 'idle',
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
bound: {},
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
actions: {
|
|
102
|
-
setBanks: assign((context, event) => {
|
|
103
|
-
const { bankList = [], paymentInfo = {} } = event.data
|
|
104
|
-
const { bankInfo = [] } = paymentInfo
|
|
105
|
-
return {
|
|
106
|
-
hasAnyAccount: bankInfo.length > 0,
|
|
107
|
-
holderName: bankInfo[0]?.holderName,
|
|
108
|
-
bankList,
|
|
109
|
-
bank: bankList[0],
|
|
110
|
-
}
|
|
111
|
-
}),
|
|
112
|
-
},
|
|
113
|
-
guards: {
|
|
114
|
-
isBindable: (context, event) => {
|
|
115
|
-
const { bank, bankAccount, firstNameTh, lastNameTh, firstNameEn, lastNameEn } = context
|
|
116
|
-
|
|
117
|
-
return bank.bankCode && bankAccount && firstNameTh && lastNameTh && firstNameEn && lastNameEn
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
services: {
|
|
121
|
-
fetchInitData: async (context, event) => {
|
|
122
|
-
const [bankList, paymentInfo] = await Promise.all([
|
|
123
|
-
request.send(payment.getBindingBankList({ appSecret })),
|
|
124
|
-
request.send(payment.getPaymentInfo()),
|
|
125
|
-
])
|
|
126
|
-
return { bankList, paymentInfo }
|
|
127
|
-
},
|
|
128
|
-
updatePaymentInfo: async (context, event) => {
|
|
129
|
-
const { bonus, bank, bankAccount, firstNameTh, lastNameTh, firstNameEn, lastNameEn } = context
|
|
130
|
-
return await request.send(
|
|
131
|
-
payment.updatePaymentInfo({
|
|
132
|
-
paymentProvider: 'amb',
|
|
133
|
-
// bonus,
|
|
134
|
-
bankCode: bank.bankCode,
|
|
135
|
-
bankAccount,
|
|
136
|
-
firstNameTh,
|
|
137
|
-
lastNameTh,
|
|
138
|
-
firstNameEn,
|
|
139
|
-
lastNameEn,
|
|
140
|
-
})
|
|
141
|
-
)
|
|
142
|
-
},
|
|
143
|
-
},
|
|
144
|
-
}
|
|
145
|
-
)
|
|
146
|
-
}
|
package/src/machine/bonus.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { assign, createMachine, send } from 'xstate'
|
|
2
|
-
import payment from '../api/payment.js'
|
|
3
|
-
|
|
4
|
-
export default function (request) {
|
|
5
|
-
return createMachine(
|
|
6
|
-
{
|
|
7
|
-
id: 'bonus',
|
|
8
|
-
predictableActionArguments: true,
|
|
9
|
-
initial: 'loading',
|
|
10
|
-
context: {
|
|
11
|
-
bonus: null,
|
|
12
|
-
},
|
|
13
|
-
states: {
|
|
14
|
-
loading: {
|
|
15
|
-
invoke: {
|
|
16
|
-
src: 'fetchInitData',
|
|
17
|
-
onDone: {
|
|
18
|
-
target: 'idle',
|
|
19
|
-
actions: 'setBonus',
|
|
20
|
-
},
|
|
21
|
-
onError: {
|
|
22
|
-
target: 'idle',
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
idle: {
|
|
27
|
-
on: {
|
|
28
|
-
TOGGLE: {
|
|
29
|
-
target: 'updating',
|
|
30
|
-
},
|
|
31
|
-
SWITCH_ON: {
|
|
32
|
-
actions: send((context, event) => ({ type: 'TOGGLE', data: 1 })),
|
|
33
|
-
cond: (context, event) => context.bonus !== 1,
|
|
34
|
-
},
|
|
35
|
-
SWITCH_OFF: {
|
|
36
|
-
actions: send((context, event) => ({ type: 'TOGGLE', data: 0 })),
|
|
37
|
-
cond: (context, event) => context.bonus !== 0,
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
updating: {
|
|
42
|
-
invoke: {
|
|
43
|
-
src: 'toggleBonus',
|
|
44
|
-
onDone: {
|
|
45
|
-
target: 'idle',
|
|
46
|
-
actions: 'setBonus',
|
|
47
|
-
},
|
|
48
|
-
onError: {
|
|
49
|
-
target: 'idle',
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
actions: {
|
|
57
|
-
setBonus: assign((context, event) => {
|
|
58
|
-
return {
|
|
59
|
-
bonus: event.data,
|
|
60
|
-
}
|
|
61
|
-
}),
|
|
62
|
-
},
|
|
63
|
-
services: {
|
|
64
|
-
fetchInitData: async (context, event) => {
|
|
65
|
-
const { bonus } = await request.send(payment.getPaymentInfo())
|
|
66
|
-
return bonus
|
|
67
|
-
},
|
|
68
|
-
toggleBonus: async (context, event) => {
|
|
69
|
-
const bonus = context.bonus ? 0 : 1
|
|
70
|
-
await request.send(payment.setBonusSetting({ bonus }))
|
|
71
|
-
return bonus
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
}
|
|
75
|
-
)
|
|
76
|
-
}
|
|
@@ -1,93 +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: 'amb',
|
|
8
|
-
predictableActionArguments: true,
|
|
9
|
-
initial: 'loading',
|
|
10
|
-
context: {
|
|
11
|
-
bankList: [],
|
|
12
|
-
userAccount: {},
|
|
13
|
-
houseAccountName: null,
|
|
14
|
-
houseAccountNumber: null,
|
|
15
|
-
houseBankName: null,
|
|
16
|
-
method: 'amb',
|
|
17
|
-
},
|
|
18
|
-
states: {
|
|
19
|
-
loading: {
|
|
20
|
-
initial: 'checkingUserAccount',
|
|
21
|
-
states: {
|
|
22
|
-
checkingUserAccount: {
|
|
23
|
-
invoke: {
|
|
24
|
-
src: 'fetchPaymentInfo',
|
|
25
|
-
onDone: [
|
|
26
|
-
{
|
|
27
|
-
target: 'initializing',
|
|
28
|
-
actions: 'setUserAccount',
|
|
29
|
-
cond: 'hasUserAccount',
|
|
30
|
-
},
|
|
31
|
-
{ target: '#amb.accountUnbound' },
|
|
32
|
-
],
|
|
33
|
-
onError: {
|
|
34
|
-
target: '#amb.unavailable',
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
initializing: {
|
|
39
|
-
invoke: {
|
|
40
|
-
src: 'initialize',
|
|
41
|
-
onDone: { target: '#amb.finish', actions: 'setInitialization' },
|
|
42
|
-
onError: {
|
|
43
|
-
target: '#amb.unavailable',
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
finish: {},
|
|
50
|
-
accountUnbound: {},
|
|
51
|
-
unavailable: {},
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
actions: {
|
|
56
|
-
setUserAccount: assign((context, event) => {
|
|
57
|
-
return {
|
|
58
|
-
userAccount: event.data?.[0],
|
|
59
|
-
}
|
|
60
|
-
}),
|
|
61
|
-
setInitialization: assign((context, event) => {
|
|
62
|
-
const { houseAccount, bankList } = event.data
|
|
63
|
-
return {
|
|
64
|
-
houseAccountName: houseAccount.accountName,
|
|
65
|
-
houseAccountNumber: houseAccount.accountNumber,
|
|
66
|
-
houseBankName: houseAccount.bankName,
|
|
67
|
-
bankList: bankList?.data ? bankList.data : bankList,
|
|
68
|
-
}
|
|
69
|
-
}),
|
|
70
|
-
},
|
|
71
|
-
guards: {
|
|
72
|
-
hasUserAccount: (context, event) => {
|
|
73
|
-
return event.data?.[0]
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
services: {
|
|
77
|
-
fetchPaymentInfo: async (context, event) => {
|
|
78
|
-
const { bankInfo } = await request.send(payment.getPaymentInfo())
|
|
79
|
-
const filterArray = bankInfo?.filter((item) => item.bindingType !== 'CRYPTO' && item.bindingType !== 'EWALLET')
|
|
80
|
-
return filterArray || []
|
|
81
|
-
},
|
|
82
|
-
initialize: async (context, event) => {
|
|
83
|
-
const { method } = context
|
|
84
|
-
const [houseAccount, bankList] = await Promise.all([
|
|
85
|
-
request.send(payment.submitDepositTransaction({ method })),
|
|
86
|
-
request.send(payment.getBankList(method)),
|
|
87
|
-
])
|
|
88
|
-
return { houseAccount, bankList }
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
}
|
|
92
|
-
)
|
|
93
|
-
}
|