@jetthai/cuora 1.1.488-dev.1 → 1.2.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.
Files changed (221) hide show
  1. package/.husky/pre-commit +3 -1
  2. package/.prettierignore +1 -2
  3. package/CHANGELOG.md +0 -746
  4. package/README.md +15 -299
  5. package/package.json +3 -6
  6. package/resetGitBranch.sh +101 -0
  7. package/src/api/activity.js +39 -24
  8. package/src/api/auth.js +35 -4
  9. package/src/api/common.js +1 -8
  10. package/src/api/game.js +10 -0
  11. package/src/api/index.js +1 -3
  12. package/src/api/payment.js +55 -18
  13. package/src/api/user.js +16 -11
  14. package/src/index.js +2 -2
  15. package/src/lib/fingerprint_v3_11_12.js +11433 -0
  16. package/src/machine/activity/activity.js +209 -0
  17. package/src/machine/activity/activity_cash.js +18 -71
  18. package/src/machine/activity/diamond_shop_activity_cash.js +1 -0
  19. package/src/machine/activity/diamond_shop_activity_fc.js +196 -0
  20. package/src/machine/activity/diamond_shop_activity_vn.js +178 -0
  21. package/src/machine/activity/fafafa_activity.js +10 -0
  22. package/src/machine/activity/index.js +12 -0
  23. package/src/machine/activity/invite_friends_activity.js +114 -0
  24. package/src/machine/activity/mini_game_activity.js +68 -0
  25. package/src/machine/activity/return_bonus_activity.js +153 -0
  26. package/src/machine/activity/roulette_activity_v2.js +0 -5
  27. package/src/machine/auth.js +140 -192
  28. package/src/machine/auth_otp_v2.js +177 -0
  29. package/src/machine/auth_otp_v3.js +32 -111
  30. package/src/machine/bank_binding.js +2 -2
  31. package/src/machine/bank_binding_amb.js +145 -0
  32. package/src/machine/bonus.js +75 -0
  33. package/src/machine/common.js +91 -27
  34. package/src/machine/deposit/amb.js +92 -0
  35. package/src/machine/deposit/crypto_bank.js +325 -0
  36. package/src/machine/deposit/crypto_bank_cash.js +8 -19
  37. package/src/machine/deposit/crypto_qrcode.js +148 -0
  38. package/src/machine/deposit/crypto_qrcode_cash.js +41 -26
  39. package/src/machine/deposit/crypto_way.js +247 -0
  40. package/src/machine/deposit/crypto_way_cash.js +32 -52
  41. package/src/machine/deposit/deposit_fc.js +271 -0
  42. package/src/machine/deposit/direct.js +310 -0
  43. package/src/machine/deposit/direct_cash.js +9 -8
  44. package/src/machine/deposit/float.js +374 -0
  45. package/src/machine/deposit/index.js +28 -0
  46. package/src/machine/deposit/krway.js +151 -0
  47. package/src/machine/deposit/loadcard_cash.js +31 -14
  48. package/src/machine/deposit/loadcard_vn.js +351 -0
  49. package/src/machine/deposit/manual_cash.js +10 -8
  50. package/src/machine/deposit/manual_vn.js +458 -0
  51. package/src/machine/deposit/qrcode_cash.js +30 -14
  52. package/src/machine/deposit/qrcode_v2.js +338 -0
  53. package/src/machine/deposit/usdt.js +144 -0
  54. package/src/machine/deposit/virtual_bank_cash.js +2 -5
  55. package/src/machine/deposit/virtual_bank_vn.js +269 -0
  56. package/src/machine/deposit/vpay.js +367 -0
  57. package/src/machine/error.js +0 -7
  58. package/src/machine/game_hot_new.js +79 -0
  59. package/src/machine/game_info.js +12 -5
  60. package/src/machine/game_replay.js +46 -0
  61. package/src/machine/game_search_v2.js +401 -0
  62. package/src/machine/game_v2_1.js +88 -58
  63. package/src/machine/honor_board.js +132 -0
  64. package/src/machine/honor_board_cash.js +18 -15
  65. package/src/machine/inbox.js +12 -0
  66. package/src/machine/index.js +32 -0
  67. package/src/machine/leaderboard.js +11 -8
  68. package/src/machine/merge.js +57 -0
  69. package/src/machine/payment_data.js +86 -0
  70. package/src/machine/promotions.js +170 -0
  71. package/src/machine/ranking.js +25 -43
  72. package/src/machine/reward.js +255 -0
  73. package/src/machine/reward_cash.js +41 -2
  74. package/src/machine/reward_fc.js +98 -0
  75. package/src/machine/roulette_v2.js +25 -20
  76. package/src/machine/side.js +154 -0
  77. package/src/machine/side_cash.js +2 -3
  78. package/src/machine/side_v2.js +209 -0
  79. package/src/machine/user_reset_password.js +15 -4
  80. package/src/machine/user_sign_up.js +60 -49
  81. package/src/machine/vip_table.js +57 -0
  82. package/src/machine/websocket.js +325 -378
  83. package/src/machine/welcome.js +110 -0
  84. package/src/machine/withdraw/index.js +6 -0
  85. package/src/machine/withdraw/withdraw_crypto_cash.js +327 -0
  86. package/src/machine/withdraw/withdraw_krway.js +222 -0
  87. package/src/machine/withdraw/withdraw_manual.js +533 -0
  88. package/src/machine/withdraw/withdraw_manual_cash.js +43 -74
  89. package/src/request/config.js +0 -2
  90. package/src/request/request.js +64 -231
  91. package/src/util/constant.js +2 -12
  92. package/src/util/deviceToken.js +59 -0
  93. package/src/util/index.js +4 -2
  94. package/src/util/math.js +4 -0
  95. package/.claude/commands/sync-ai-prompts.md +0 -180
  96. package/.claude/settings.local.json +0 -25
  97. package/.github/copilot-instructions.md +0 -459
  98. package/.husky/post-checkout +0 -32
  99. package/.husky/pre-push +0 -36
  100. package/AGENTS.md +0 -459
  101. package/AI_PROMPT_SOURCE.md +0 -457
  102. package/CLAUDE.md +0 -459
  103. package/GEMINI.md +0 -459
  104. package/docs/kibana/crypto-way-deposit-amount-bug-analysis.md +0 -1003
  105. package/docs/kibana/play-providerId-error.md +0 -202
  106. package/docs/kibana/play-selectedWalletType.md +0 -1
  107. package/docs/kibana/play-selectedWalletType_2.md +0 -1
  108. package/docs/kibana/play-selectedWalletType_analysis.md +0 -565
  109. package/docs/my-claude/feat-sharon-JT-1790247240-socket/branch-transfer.md +0 -14
  110. package/docs/my-claude/feat-sharon-JT-1790247240-socket/cash-module-preparation.json +0 -40
  111. package/docs/my-claude/feat-sharon-JT-1790247240-socket/cash-module-verification.md +0 -41
  112. package/docs/my-claude/feat-sharon-JT-1790247240-socket/implementation-ledger.md +0 -87
  113. package/docs/my-claude/feat-sharon-JT-1790247240-socket/module-report.md +0 -73
  114. package/docs/my-claude/feat-sharon-JT-1790247240-socket/plan.md +0 -309
  115. package/docs/my-claude/feat-sharon-JT-1790247240-socket/test-cases.md +0 -245
  116. package/docs/my-claude/feat-sharon-JT-1791180540-onesignal/transfer.md +0 -9
  117. package/e2e/feature-map.md +0 -19
  118. package/prepare-for-pr/JT-1776243420.md +0 -85
  119. package/prepare-for-pr/TI-16026/STATE.md +0 -18
  120. package/prepare-for-pr/TI-16026/after-prepare-authorization.md +0 -3
  121. package/prepare-for-pr/TI-16026/analysis.md +0 -38
  122. package/prepare-for-pr/TI-16026/answer-analyze-01.md +0 -1
  123. package/prepare-for-pr/TI-16026/answer-commit-01.md +0 -2
  124. package/prepare-for-pr/TI-16026/answer-commit-02.md +0 -1
  125. package/prepare-for-pr/TI-16026/bundle.json +0 -18
  126. package/prepare-for-pr/TI-16026/checklist.md +0 -196
  127. package/prepare-for-pr/TI-16026/checklist.unit-test-original.md +0 -39
  128. package/prepare-for-pr/TI-16026/claude-after-model +0 -1
  129. package/prepare-for-pr/TI-16026/claude-commit-session +0 -1
  130. package/prepare-for-pr/TI-16026/claude-harvest-session +0 -1
  131. package/prepare-for-pr/TI-16026/claude-hops/01-analyze.err +0 -1
  132. package/prepare-for-pr/TI-16026/claude-hops/01-analyze.out +0 -2
  133. package/prepare-for-pr/TI-16026/claude-hops/02-analyze.err +0 -1
  134. package/prepare-for-pr/TI-16026/claude-hops/02-analyze.out +0 -4
  135. package/prepare-for-pr/TI-16026/claude-hops/03-dev.err +0 -1
  136. package/prepare-for-pr/TI-16026/claude-hops/03-dev.out +0 -4
  137. package/prepare-for-pr/TI-16026/claude-hops/04-dev.err +0 -1
  138. package/prepare-for-pr/TI-16026/claude-hops/04-dev.out +0 -4
  139. package/prepare-for-pr/TI-16026/claude-hops/05-dev.err +0 -1
  140. package/prepare-for-pr/TI-16026/claude-hops/05-dev.out +0 -3
  141. package/prepare-for-pr/TI-16026/claude-hops/06-after.err +0 -1
  142. package/prepare-for-pr/TI-16026/claude-hops/06-after.out +0 -2
  143. package/prepare-for-pr/TI-16026/claude-hops/07-commit.err +0 -1
  144. package/prepare-for-pr/TI-16026/claude-hops/07-commit.out +0 -2
  145. package/prepare-for-pr/TI-16026/claude-hops/08-commit.err +0 -1
  146. package/prepare-for-pr/TI-16026/claude-hops/08-commit.out +0 -2
  147. package/prepare-for-pr/TI-16026/claude-hops/09-commit.err +0 -1
  148. package/prepare-for-pr/TI-16026/claude-hops/09-commit.out +0 -8
  149. package/prepare-for-pr/TI-16026/claude-hops/10-harvest.err +0 -1
  150. package/prepare-for-pr/TI-16026/claude-hops/10-harvest.out +0 -3
  151. package/prepare-for-pr/TI-16026/claude-hops/11-harvest.err +0 -1
  152. package/prepare-for-pr/TI-16026/claude-hops/11-harvest.out +0 -3
  153. package/prepare-for-pr/TI-16026/commit-note.md +0 -5
  154. package/prepare-for-pr/TI-16026/evidence-index.json +0 -215
  155. package/prepare-for-pr/TI-16026/feature-map.before.md +0 -61
  156. package/prepare-for-pr/TI-16026/harvest-redaction.json +0 -34
  157. package/prepare-for-pr/TI-16026/harvest-redaction.out +0 -37
  158. package/prepare-for-pr/TI-16026/harvest.md +0 -46
  159. package/prepare-for-pr/TI-16026/lessons.md +0 -5
  160. package/prepare-for-pr/TI-16026/note-harvest-redaction.md +0 -1
  161. package/prepare-for-pr/TI-16026/open-questions.md +0 -6
  162. package/prepare-for-pr/TI-16026/publish.md +0 -32
  163. package/prepare-for-pr/TI-16026/review-convergence-response.md +0 -3
  164. package/prepare-for-pr/TI-16026/review-input/scope.md +0 -18
  165. package/prepare-for-pr/TI-16026/review-log.md +0 -57
  166. package/prepare-for-pr/TI-16026/review-notes.md +0 -97
  167. package/prepare-for-pr/TI-16026/review-response-r1.md +0 -7
  168. package/prepare-for-pr/TI-16026/self-test-report.md +0 -67
  169. package/prepare-for-pr/TI-16026/spec-proposal.md +0 -34
  170. package/prepare-for-pr/TI-16026/spec-snapshot.md +0 -291
  171. package/prepare-for-pr/TI-16026/state-log.md +0 -57
  172. package/prepare-for-pr/TI-16026/user-messages/01.md +0 -12
  173. package/prepare-for-pr/TI-16026/user-messages/02.md +0 -20
  174. package/prepare-for-pr/TI-16026/user-messages/03.md +0 -1
  175. package/prepare-for-pr/TI-16026/user-messages/04.md +0 -1
  176. package/prepare-for-pr/TI-16026/user-messages/05.md +0 -1
  177. package/prepare-for-pr/TI-16026/user-messages/06.md +0 -1
  178. package/prepare-for-pr/TI-16026/user-messages/07.md +0 -1
  179. package/prepare-for-pr/TI-16026/user-messages/08.md +0 -1
  180. package/prepare-for-pr/TI-16026/user-messages/09.md +0 -1
  181. package/prepare-for-pr/TI-16026/user-messages/10.md +0 -1
  182. package/prepare-for-pr/TI-16026/user-messages/11.md +0 -1
  183. package/prepare-for-pr/TI-16026/user-messages/12.md +0 -1
  184. package/prepare-for-pr/TI-16026/user-messages/13.md +0 -1
  185. package/prepare-for-pr/TI-16026/user-messages/14.md +0 -1
  186. package/prepare-for-pr/TI-16026/user-messages/15.md +0 -1
  187. package/prepare-for-pr/TI-16026/user-messages/16.md +0 -1
  188. package/prepare-for-pr/TI-16026/user-messages/17.md +0 -1
  189. package/prepare-for-pr/TI-16026/user-messages/18.md +0 -10
  190. package/prepare-for-pr/TI-16026/user-messages/19.md +0 -1
  191. package/prepare-for-pr/TI-16026/user-messages/20.md +0 -1
  192. package/prepare-for-pr/TI-16026/user-messages/21.md +0 -1
  193. package/prepare-for-pr/TI-16026/user-messages/22.md +0 -1
  194. package/prepare-for-pr/TI-16026/user-messages/23.md +0 -8
  195. package/prepare-for-pr/TI-16026/user-messages/24.md +0 -24
  196. package/prepare-for-pr/TI-16026/user-question.md +0 -24
  197. package/prepare-for-pr/TI-16026/verify/metrics-check.json +0 -13
  198. package/prepare-for-pr/TI-16026/verify/redaction.json +0 -38
  199. package/prepare-for-pr/TI-16026/verify/row-closure.json +0 -45
  200. package/prepare-for-pr/TI-16026/verify/s04-ws-capture.md +0 -23
  201. package/prepare-for-pr/TI-16026/verify-after.md +0 -23
  202. package/prepare-for-pr/TI-16026/verify.json +0 -80
  203. package/prepare-for-pr/TI-16026.md +0 -408
  204. package/scripts/auto-version.js +0 -69
  205. package/scripts/auto-version.sh +0 -33
  206. package/scripts/branch-auto-npm-publish.js +0 -36
  207. package/scripts/check-version.sh +0 -36
  208. package/scripts/clean-tags.sh +0 -84
  209. package/src/api/account.js +0 -7
  210. package/src/api/otp.js +0 -5
  211. package/src/util/amount.js +0 -8
  212. package/src/util/err998SentryExtra.js +0 -26
  213. package/src/util/paramStore.js +0 -139
  214. package/src/util/socketPolicy.js +0 -57
  215. package/src/util/tokenStore.js +0 -44
  216. package/test/auth_otp_v3.test.js +0 -323
  217. package/test/auth_self_timeout.test.js +0 -171
  218. package/test/request_self.test.js +0 -288
  219. package/test/withdraw_manual_cash.test.js +0 -149
  220. package/tests/session.test.mjs +0 -177
  221. package/tests/websocket.test.mjs +0 -779
@@ -0,0 +1,374 @@
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: 'float',
10
+ initial: 'loading',
11
+ context: {
12
+ method: 'amb_float',
13
+ userAccount: {},
14
+ siteConfig: null,
15
+ amount: 0,
16
+
17
+ bankList: [],
18
+ options: [],
19
+ minimum: 0,
20
+ maximum: 0,
21
+
22
+ calculation: null,
23
+
24
+ houseAccountName: null,
25
+ houseAccountNumber: null,
26
+ houseBankName: null,
27
+ calculatedAmount: 0,
28
+
29
+ grandTotalEnable: 1,
30
+ ttl: 120,
31
+
32
+ promotion: null,
33
+ bonusPreviewData: [],
34
+ },
35
+ states: {
36
+ loading: {
37
+ initial: 'checkingUserAccount',
38
+ states: {
39
+ checkingUserAccount: {
40
+ invoke: {
41
+ src: 'fetchPaymentInfo',
42
+ onDone: [
43
+ {
44
+ target: 'initializing',
45
+ actions: 'setUserAccount',
46
+ cond: 'hasUserAccount',
47
+ },
48
+ { target: '#float.accountUnbound' },
49
+ ],
50
+ onError: {
51
+ target: '#float.unavailable',
52
+ },
53
+ },
54
+ },
55
+ initializing: {
56
+ invoke: {
57
+ src: 'initialize',
58
+ onDone: {
59
+ target: '#float.loaded',
60
+ actions: 'setInitialization',
61
+ },
62
+ onError: {
63
+ target: '#float.unavailable',
64
+ },
65
+ },
66
+ },
67
+ },
68
+ },
69
+ checking: {
70
+ always: [
71
+ {
72
+ target: 'fetching',
73
+ cond: (context, event) => {
74
+ const { siteConfig = {}, promotion = {} } = context
75
+ const { bonusPreviewEnable } = siteConfig
76
+ return bonusPreviewEnable && promotion.activityNo != 'none'
77
+ },
78
+ },
79
+ { target: 'loaded' },
80
+ ],
81
+ },
82
+ fetching: {
83
+ invoke: {
84
+ src: 'fetchBonusPreview',
85
+ onDone: {
86
+ target: 'loaded',
87
+ actions: 'setBonusPreview',
88
+ },
89
+ onError: {
90
+ target: 'loaded',
91
+ },
92
+ },
93
+ },
94
+ loaded: {
95
+ on: {
96
+ SELECT_AMOUNT: [
97
+ {
98
+ target: 'debouncing',
99
+ actions: 'addAmount',
100
+ cond: 'isGrandTotalEnable',
101
+ },
102
+ {
103
+ target: 'debouncing',
104
+ actions: 'setAmount',
105
+ },
106
+ ],
107
+ KEY_IN: {
108
+ target: 'calculating',
109
+ actions: 'setAmount',
110
+ },
111
+ CLEAR_CALCULATION: {
112
+ target: 'debouncing',
113
+ actions: 'clearCalculation',
114
+ },
115
+ },
116
+ },
117
+ debouncing: {
118
+ on: {
119
+ SELECT_AMOUNT: [
120
+ {
121
+ target: 'debouncing',
122
+ actions: 'addAmount',
123
+ cond: 'isGrandTotalEnable',
124
+ },
125
+ {
126
+ target: 'debouncing',
127
+ actions: 'setAmount',
128
+ },
129
+ ],
130
+ KEY_IN: {
131
+ target: 'debouncing',
132
+ actions: 'setAmount',
133
+ },
134
+ },
135
+ after: {
136
+ 1000: {
137
+ target: 'calculating',
138
+ },
139
+ },
140
+ },
141
+ calculable: {
142
+ entry: 'clearCalculation',
143
+ on: {
144
+ SELECT_AMOUNT: [
145
+ {
146
+ target: 'debouncing',
147
+ actions: 'addAmount',
148
+ cond: 'isGrandTotalEnable',
149
+ },
150
+ {
151
+ target: 'debouncing',
152
+ actions: 'setAmount',
153
+ },
154
+ ],
155
+ KEY_IN: {
156
+ target: 'debouncing',
157
+ actions: 'setAmount',
158
+ },
159
+ CLEAR_CALCULATION: {
160
+ target: 'debouncing',
161
+ actions: 'clearCalculation',
162
+ },
163
+ CLEAR: {
164
+ actions: 'setAmount',
165
+ },
166
+ },
167
+ },
168
+ calculating: {
169
+ invoke: {
170
+ src: 'fetchCalculation',
171
+ onDone: {
172
+ target: 'calculated',
173
+ actions: 'setCalculation',
174
+ },
175
+ onError: {
176
+ target: 'calculable',
177
+ },
178
+ },
179
+ },
180
+ calculated: {
181
+ on: {
182
+ SELECT_AMOUNT: [
183
+ {
184
+ target: 'debouncing',
185
+ actions: 'addAmount',
186
+ cond: 'isGrandTotalEnable',
187
+ },
188
+ {
189
+ target: 'debouncing',
190
+ actions: 'setAmount',
191
+ },
192
+ ],
193
+ KEY_IN: {
194
+ target: 'debouncing',
195
+ actions: 'setAmount',
196
+ },
197
+ CONFIRM: {
198
+ target: 'submitting',
199
+ },
200
+ CLEAR: {
201
+ actions: 'setAmount',
202
+ },
203
+ CLEAR_CALCULATION: {
204
+ target: 'debouncing',
205
+ actions: 'clearCalculation',
206
+ },
207
+ },
208
+ },
209
+ submitting: {
210
+ invoke: {
211
+ src: 'submitDeposit',
212
+ onDone: {
213
+ target: 'countdown',
214
+ actions: 'setHouseBank',
215
+ },
216
+ onError: {
217
+ target: 'calculated',
218
+ },
219
+ },
220
+ },
221
+ countdown: {
222
+ after: {
223
+ 1000: [
224
+ {
225
+ target: 'countdown',
226
+ actions: 'decreaseTtl',
227
+ cond: (context) => context.ttl > 0,
228
+ },
229
+ {
230
+ target: 'loaded',
231
+ },
232
+ ],
233
+ },
234
+ },
235
+ accountUnbound: {},
236
+ unavailable: {},
237
+ },
238
+ on: {
239
+ SET_PROMOTION: {
240
+ actions: 'setPromotion',
241
+ },
242
+ },
243
+ },
244
+ {
245
+ actions: {
246
+ setUserAccount: assign((context, event) => {
247
+ return {
248
+ userAccount: event.data?.[0],
249
+ }
250
+ }),
251
+ setPromotion: assign((context, event) => {
252
+ const promotion = event.data
253
+ return {
254
+ promotion,
255
+ }
256
+ }),
257
+ setBonusPreview: assign((context, event) => {
258
+ return {
259
+ bonusPreviewData: event.data,
260
+ }
261
+ }),
262
+ setHouseBank: assign((context, event) => {
263
+ const { accountName, accountNumber, bankName, amount } = event.data
264
+ return {
265
+ houseAccountName: accountName,
266
+ houseAccountNumber: accountNumber,
267
+ houseBankName: bankName,
268
+ calculatedAmount: amount,
269
+ }
270
+ }),
271
+ setInitialization: assign((context, event) => {
272
+ const { siteConfig, housePayment, bankList } = event.data
273
+ const { optional, minimum, maximum, grandTotalEnable } = housePayment
274
+ return {
275
+ siteConfig,
276
+ options: optional,
277
+ minimum,
278
+ maximum,
279
+ bankList: bankList?.data ? bankList.data : bankList,
280
+ grandTotalEnable,
281
+ }
282
+ }),
283
+ addAmount: assign((context, event) => {
284
+ const { amount, maximum } = context
285
+ return {
286
+ amount: Math.min(amount + event.data, maximum),
287
+ }
288
+ }),
289
+ setAmount: assign((context, event) => {
290
+ return {
291
+ amount: event.data,
292
+ }
293
+ }),
294
+ setCalculation: assign((context, event) => {
295
+ // V2接口轉換中回傳的資料結構不同
296
+ const { data } = event.data
297
+ if (data) {
298
+ return {
299
+ calculation: data,
300
+ }
301
+ } else {
302
+ return {
303
+ calculation: event.data,
304
+ }
305
+ }
306
+ }),
307
+ clearCalculation: assign((context, event) => {
308
+ return {
309
+ calculation: null,
310
+ }
311
+ }),
312
+ decreaseTtl: assign((context, evnet) => {
313
+ const ms = context.ttl
314
+ return {
315
+ ttl: Math.max(ms - 1, 0),
316
+ }
317
+ }),
318
+ },
319
+ guards: {
320
+ hasUserAccount: (context, event) => {
321
+ return event.data?.[0]
322
+ },
323
+ isGrandTotalEnable: (context, event) => {
324
+ return context.grandTotalEnable === 1
325
+ },
326
+ },
327
+ services: {
328
+ fetchPaymentInfo: async (context, event) => {
329
+ const { bankInfo } = await request.send(payment.getPaymentInfo())
330
+ const filterArray = bankInfo?.filter((item) => item.bindingType !== 'CRYPTO' && item.bindingType !== 'EWALLET')
331
+ return filterArray || []
332
+ },
333
+ initialize: async (context, event) => {
334
+ const [{ config }, payments, bankList] = await Promise.all([
335
+ request.send(common.getConfig({ appSecret })),
336
+ request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' })),
337
+ request.send(payment.getBankList('amb')),
338
+ ])
339
+ const siteConfig = JSON.parse(window.atob(config))
340
+ return { siteConfig, housePayment: payments.find((payment) => payment.method === context.method), bankList }
341
+ },
342
+ fetchBonusPreview: async (context, event) => {
343
+ const { method, promotion } = context
344
+ return await request.send(
345
+ payment.getBonusPreview({
346
+ method,
347
+ promotionsNo: promotion?.activityNo,
348
+ })
349
+ )
350
+ },
351
+ submitDeposit: async (context, event) => {
352
+ const { method, amount, promotion } = context
353
+ return await request.send(
354
+ payment.submitDepositTransaction({
355
+ method,
356
+ amount,
357
+ promotionsNo: promotion?.activityNo,
358
+ })
359
+ )
360
+ },
361
+ fetchCalculation: async (context, event) => {
362
+ const { method, amount, promotion } = context
363
+ return await request.send(
364
+ payment.getDepositExpectedResult({
365
+ method,
366
+ amount: Number(amount),
367
+ promotionsNo: promotion?.activityNo,
368
+ })
369
+ )
370
+ },
371
+ },
372
+ }
373
+ )
374
+ }
@@ -1,21 +1,49 @@
1
+ import manual_vn from './manual_vn.js'
2
+ import loadcard_vn from './loadcard_vn.js'
3
+ import qrcode_v2 from './qrcode_v2.js'
4
+ import deposit_fc from './deposit_fc.js'
5
+ import direct from './direct.js'
6
+ import amb from './amb.js'
7
+ import float from './float.js'
8
+ import vpay from './vpay.js'
9
+ import krway from './krway.js'
10
+ import usdt from './usdt.js'
1
11
  import manual_cash from './manual_cash.js'
2
12
  import qrcode_cash from './qrcode_cash.js'
3
13
  import usdt_cash from './usdt_cash.js'
4
14
  import direct_cash from './direct_cash.js'
5
15
  import loadcard_cash from './loadcard_cash.js'
16
+ import crypto_bank from './crypto_bank.js'
17
+ import crypto_qrcode from './crypto_qrcode.js'
18
+ import crypto_way from './crypto_way.js'
6
19
  import crypto_bank_cash from './crypto_bank_cash.js'
7
20
  import crypto_qrcode_cash from './crypto_qrcode_cash.js'
8
21
  import crypto_way_cash from './crypto_way_cash.js'
22
+ import virtual_bank_vn from './virtual_bank_vn.js'
9
23
  import virtual_bank_cash from './virtual_bank_cash.js'
10
24
 
11
25
  export default {
26
+ manual_vn,
27
+ loadcard_vn,
28
+ qrcode_v2,
29
+ deposit_fc,
30
+ direct,
31
+ amb,
32
+ float,
33
+ vpay,
34
+ usdt,
35
+ krway,
12
36
  manual_cash,
13
37
  qrcode_cash,
14
38
  usdt_cash,
15
39
  direct_cash,
16
40
  loadcard_cash,
41
+ crypto_bank,
42
+ crypto_qrcode,
43
+ crypto_way,
17
44
  crypto_bank_cash,
18
45
  crypto_qrcode_cash,
19
46
  crypto_way_cash,
47
+ virtual_bank_vn,
20
48
  virtual_bank_cash,
21
49
  }
@@ -0,0 +1,151 @@
1
+ import { assign, createMachine } from 'xstate'
2
+ import payment from '../../api/payment.js'
3
+ import mailbox from '../../api/mailbox.js'
4
+
5
+ export default function (request) {
6
+ return createMachine(
7
+ {
8
+ id: 'krway',
9
+ initial: 'loading',
10
+ context: {
11
+ currentCategory: 'krway',
12
+ paymentDetail: [],
13
+ currentPayment: null,
14
+ options: [],
15
+ amount: null,
16
+ processing: null,
17
+ },
18
+ states: {
19
+ loading: {
20
+ invoke: {
21
+ src: 'fetchPaymentDetail',
22
+ onDone: {
23
+ target: 'checking',
24
+ actions: 'setPaymentDetail',
25
+ },
26
+ onError: {
27
+ target: 'fail',
28
+ },
29
+ },
30
+ },
31
+ checking: {
32
+ always: [
33
+ {
34
+ target: 'processing',
35
+ cond: 'isProcessing',
36
+ },
37
+ {
38
+ target: 'idle',
39
+ },
40
+ ],
41
+ },
42
+ processing: {},
43
+ idle: {},
44
+ inquiring: {
45
+ invoke: {
46
+ src: 'accountInquiry',
47
+ onDone: {
48
+ target: 'inquired',
49
+ },
50
+ onError: {
51
+ target: 'idle',
52
+ },
53
+ },
54
+ },
55
+ inquired: {
56
+ after: {
57
+ 0: {
58
+ target: 'idle',
59
+ },
60
+ },
61
+ },
62
+ submitting: {
63
+ invoke: {
64
+ src: 'submitDeposit',
65
+ onDone: {
66
+ target: 'submitted',
67
+ actions: 'setProcessing',
68
+ },
69
+ onError: {
70
+ target: 'fail',
71
+ },
72
+ },
73
+ },
74
+ submitted: {},
75
+ fail: {},
76
+ },
77
+ on: {
78
+ INQUIRY_ACCOUNT: {
79
+ target: 'inquiring',
80
+ },
81
+ ADD_AMOUNT: {
82
+ actions: 'addAmount',
83
+ },
84
+ SET_AMOUNT: {
85
+ actions: 'setAmount',
86
+ },
87
+ CLEAR_AMOUNT: {
88
+ actions: 'clearAmount',
89
+ },
90
+ SUBMIT: {
91
+ target: 'submitting',
92
+ },
93
+ },
94
+ },
95
+ {
96
+ actions: {
97
+ setPaymentDetail: assign((context, event) => {
98
+ const paymentDetail = event.data
99
+ const payments = paymentDetail.filter((item) => item.category === context.currentCategory)
100
+ const currentPayment = payments[0]
101
+ const options = currentPayment.optional || []
102
+
103
+ return {
104
+ currentPayment,
105
+ options,
106
+ processing: currentPayment.processing?.[0],
107
+ }
108
+ }),
109
+ addAmount: assign((context, event) => {
110
+ return {
111
+ amount: parseFloat(`${context.amount || 0}`) + parseFloat(`${event.data}`),
112
+ }
113
+ }),
114
+ setAmount: assign((context, event) => {
115
+ return { amount: parseFloat(`${event.data}`) }
116
+ }),
117
+ clearAmount: assign((context, event) => {
118
+ return { amount: null }
119
+ }),
120
+ setProcessing: assign((context, event) => {
121
+ return {
122
+ processing: event.data,
123
+ }
124
+ }),
125
+ },
126
+ guards: {
127
+ isProcessing: (context, event) => {
128
+ return context.processing
129
+ },
130
+ },
131
+ services: {
132
+ fetchPaymentDetail: async (context, event) => {
133
+ return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
134
+ },
135
+ accountInquiry: async (context, event) => {
136
+ const { from, title, content } = event.data
137
+ return await request.send(mailbox.sendMessage({ type: 'CUSTOMER', category: 'DEPOSIT', from, to: 'SYSTEM', title, content }))
138
+ },
139
+ submitDeposit: async (context, event) => {
140
+ const { currentPayment, amount } = context
141
+ return await request.send(
142
+ payment.submitDepositTransaction({
143
+ method: currentPayment.method,
144
+ amount,
145
+ })
146
+ )
147
+ },
148
+ },
149
+ }
150
+ )
151
+ }
@@ -1,6 +1,6 @@
1
1
  import { assign, createMachine } from 'xstate'
2
2
  import payment from '../../api/payment.js'
3
- import { isAmountInRange } from '../../util/amount.js'
3
+ import { max } from '../../util'
4
4
 
5
5
  export default function (request, context) {
6
6
  const { paymentDetail = [], promotion, selectedAmount } = context || {}
@@ -34,7 +34,22 @@ export default function (request, context) {
34
34
  debouncing: {
35
35
  entry: 'clearCalculation',
36
36
  after: {
37
- 1000: [{ target: 'calculating', cond: 'isCalculable' }, { target: 'loaded' }],
37
+ 1000: [
38
+ {
39
+ target: 'calculating',
40
+ cond: (context, event) => {
41
+ const { selectedLoadcard, selectedAmount } = context
42
+ if (selectedLoadcard && selectedAmount) {
43
+ return selectedLoadcard.minimum <= selectedAmount && selectedAmount <= selectedLoadcard.maximum
44
+ } else {
45
+ return false
46
+ }
47
+ },
48
+ },
49
+ {
50
+ target: 'loaded',
51
+ },
52
+ ],
38
53
  },
39
54
  },
40
55
  calculating: {
@@ -81,7 +96,6 @@ export default function (request, context) {
81
96
  target: '.debouncing',
82
97
  actions: 'setPromotion',
83
98
  internal: false,
84
- cond: 'isPromotionChanged',
85
99
  },
86
100
  SELECT_LOADCARD: {
87
101
  target: '.debouncing',
@@ -98,7 +112,7 @@ export default function (request, context) {
98
112
  {
99
113
  actions: {
100
114
  setInitData: assign((context, event) => {
101
- const { paymentDetail } = context
115
+ const { paymentDetail, selectedAmount, promotion } = context
102
116
  const loadcards = paymentDetail.filter((element) => element.category === context.currentCategory && element.transferType === 'deposit')
103
117
  const selectedLoadcard = loadcards[0]
104
118
  return {
@@ -106,22 +120,30 @@ export default function (request, context) {
106
120
  loadcards,
107
121
  selectedLoadcard,
108
122
  options: selectedLoadcard?.optional,
123
+ selectedAmount: max(promotion?.minimumAmount, selectedLoadcard?.minimum, selectedAmount, 0),
109
124
  }
110
125
  }),
111
126
  setPromotion: assign((context, event) => {
112
- // 通道清單不隨活動改變(loadcards 由 setInitData 從 paymentDetail 產生),
113
- // 因此切換活動只清計算結果、保留使用者已選的通道;重設成 loadcards[0] 會讓
114
- // 使用者選的通道被打回第一個,且重算的是錯誤通道的獎金
127
+ const { selectedAmount } = context
128
+ const promotion = event.data
129
+ const loadcards = context.loadcards
130
+ const selectedLoadcard = loadcards[0]
115
131
  return {
116
- promotion: event.data,
132
+ promotion,
133
+ loadcards,
134
+ selectedLoadcard,
135
+ options: selectedLoadcard?.optional,
136
+ selectedAmount: max(promotion.minimumAmount, selectedLoadcard?.minimum, selectedAmount, 0),
117
137
  calculation: null,
118
138
  }
119
139
  }),
120
140
  setLoadcard: assign((context, event) => {
141
+ const { promotion, selectedAmount } = context
121
142
  const selectedLoadcard = event.data
122
143
  return {
123
144
  selectedLoadcard,
124
145
  options: selectedLoadcard.optional,
146
+ selectedAmount: max(promotion.minimumAmount, selectedAmount, 0),
125
147
  calculation: null,
126
148
  }
127
149
  }),
@@ -162,12 +184,7 @@ export default function (request, context) {
162
184
  }
163
185
  }),
164
186
  },
165
- guards: {
166
- isPromotionChanged: (context, event) => {
167
- return event.data?.promotionsNo !== context.promotion?.promotionsNo
168
- },
169
- isCalculable: ({ selectedLoadcard, selectedAmount }) => isAmountInRange(selectedAmount, selectedLoadcard),
170
- },
187
+ guards: {},
171
188
  services: {
172
189
  fetchCalculation: async (context, event) => {
173
190
  const { selectedLoadcard, selectedAmount, promotion } = context