@jetthai/cuora 1.1.468 → 1.1.470-dev.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 (83) hide show
  1. package/.claude/commands/sync-ai-prompts.md +88 -1
  2. package/.claude/settings.local.json +3 -1
  3. package/.github/copilot-instructions.md +64 -57
  4. package/.husky/post-checkout +3 -3
  5. package/.husky/pre-push +1 -1
  6. package/.prettierignore +2 -1
  7. package/AGENTS.md +64 -57
  8. package/AI_PROMPT_SOURCE.md +64 -57
  9. package/CHANGELOG.md +186 -2
  10. package/CLAUDE.md +64 -57
  11. package/GEMINI.md +64 -57
  12. package/README.md +11 -12
  13. package/package.json +1 -1
  14. package/scripts/auto-version.js +1 -0
  15. package/scripts/branch-auto-npm-publish.js +9 -2
  16. package/src/api/account.js +0 -1
  17. package/src/api/activity.js +0 -37
  18. package/src/api/auth.js +0 -31
  19. package/src/api/game.js +0 -10
  20. package/src/api/payment.js +0 -52
  21. package/src/api/user.js +4 -22
  22. package/src/index.js +2 -2
  23. package/src/machine/activity/activity_cash.js +23 -15
  24. package/src/machine/activity/diamond_shop_activity_cash.js +0 -1
  25. package/src/machine/activity/fafafa_activity.js +0 -10
  26. package/src/machine/activity/index.js +0 -12
  27. package/src/machine/auth.js +37 -69
  28. package/src/machine/auth_otp_v3.js +0 -3
  29. package/src/machine/common.js +0 -55
  30. package/src/machine/deposit/index.js +0 -28
  31. package/src/machine/deposit/manual_cash.js +0 -8
  32. package/src/machine/game_info.js +1 -12
  33. package/src/machine/game_v2_1.js +1 -89
  34. package/src/machine/inbox.js +0 -12
  35. package/src/machine/index.js +0 -32
  36. package/src/machine/reward_cash.js +0 -39
  37. package/src/machine/user_reset_password.js +0 -13
  38. package/src/machine/user_sign_up.js +6 -1
  39. package/src/machine/websocket.js +0 -4
  40. package/src/machine/withdraw/index.js +0 -6
  41. package/src/request/request.js +0 -28
  42. package/src/util/constant.js +0 -1
  43. package/src/util/index.js +1 -4
  44. package/src/machine/activity/activity.js +0 -209
  45. package/src/machine/activity/diamond_shop_activity_fc.js +0 -196
  46. package/src/machine/activity/diamond_shop_activity_vn.js +0 -178
  47. package/src/machine/activity/invite_friends_activity.js +0 -114
  48. package/src/machine/activity/mini_game_activity.js +0 -68
  49. package/src/machine/activity/return_bonus_activity.js +0 -153
  50. package/src/machine/auth_otp_v2.js +0 -177
  51. package/src/machine/bank_binding_amb.js +0 -146
  52. package/src/machine/bonus.js +0 -76
  53. package/src/machine/deposit/amb.js +0 -93
  54. package/src/machine/deposit/crypto_bank.js +0 -330
  55. package/src/machine/deposit/crypto_qrcode.js +0 -148
  56. package/src/machine/deposit/crypto_way.js +0 -252
  57. package/src/machine/deposit/deposit_fc.js +0 -272
  58. package/src/machine/deposit/direct.js +0 -310
  59. package/src/machine/deposit/float.js +0 -375
  60. package/src/machine/deposit/krway.js +0 -151
  61. package/src/machine/deposit/loadcard_vn.js +0 -351
  62. package/src/machine/deposit/manual_vn.js +0 -458
  63. package/src/machine/deposit/qrcode_v2.js +0 -338
  64. package/src/machine/deposit/usdt.js +0 -144
  65. package/src/machine/deposit/virtual_bank_vn.js +0 -269
  66. package/src/machine/deposit/vpay.js +0 -368
  67. package/src/machine/game_hot_new.js +0 -79
  68. package/src/machine/game_replay.js +0 -46
  69. package/src/machine/game_search_v2.js +0 -401
  70. package/src/machine/honor_board.js +0 -132
  71. package/src/machine/merge.js +0 -57
  72. package/src/machine/payment_data.js +0 -86
  73. package/src/machine/promotions.js +0 -170
  74. package/src/machine/reward.js +0 -255
  75. package/src/machine/reward_fc.js +0 -98
  76. package/src/machine/side.js +0 -154
  77. package/src/machine/side_v2.js +0 -211
  78. package/src/machine/vip_table.js +0 -57
  79. package/src/machine/welcome.js +0 -110
  80. package/src/machine/withdraw/withdraw_crypto_cash.js +0 -327
  81. package/src/machine/withdraw/withdraw_krway.js +0 -223
  82. package/src/machine/withdraw/withdraw_manual.js +0 -536
  83. package/src/util/math.js +0 -4
@@ -1,252 +0,0 @@
1
- import { assign, createMachine } from 'xstate'
2
- import padStart from 'lodash/padStart.js'
3
- import payment from '@jetthai/cuora/src/api/payment.js'
4
- import common from '../../api/common.js'
5
-
6
- export default function (request) {
7
- const { appSecret } = request.config
8
- return createMachine(
9
- {
10
- id: 'crypto_way',
11
- initial: 'loading',
12
- context: {
13
- paymentDetails: [],
14
-
15
- cryptos: [],
16
- sourceAddress: '',
17
-
18
- amount: null,
19
- selectedCrypto: null,
20
-
21
- currentCategory: 'cryptoWay',
22
- currentPayment: null,
23
-
24
- calculation: null,
25
- result: null,
26
-
27
- // use for wallet mode 4
28
- promotion: null,
29
- },
30
- states: {
31
- loading: {
32
- invoke: {
33
- src: 'fetchPayments',
34
- onDone: {
35
- target: 'loaded',
36
- actions: 'setPayment',
37
- },
38
- onError: {
39
- target: '#crypto_way.fail',
40
- },
41
- },
42
- },
43
- loaded: {
44
- always: [{ target: 'debouncing', cond: 'isCalculable' }],
45
- },
46
- debouncing: {
47
- after: {
48
- 1000: {
49
- target: 'calculating',
50
- },
51
- },
52
- },
53
- calculating: {
54
- invoke: {
55
- src: 'fetchCalculation',
56
- onDone: {
57
- target: 'calculated',
58
- actions: 'setCalculation',
59
- },
60
- onError: {
61
- target: 'loaded',
62
- },
63
- },
64
- },
65
- calculated: {
66
- on: {
67
- SUBMIT: [
68
- {
69
- target: 'pending',
70
- },
71
- {
72
- target: 'submitting',
73
- cond: 'isSubmittable',
74
- },
75
- ],
76
- },
77
- },
78
- pending: {
79
- on: {
80
- SUBMIT: {
81
- target: 'submitting',
82
- cond: 'isSubmittable',
83
- },
84
- },
85
- },
86
- submitting: {
87
- invoke: {
88
- src: 'submitDeposit',
89
- onDone: {
90
- target: 'submitted',
91
- actions: 'setResult',
92
- },
93
- onError: {
94
- target: 'submitFail',
95
- },
96
- },
97
- },
98
- submitFail: {
99
- after: {
100
- 0: { target: 'loaded' },
101
- },
102
- },
103
- submitted: {},
104
- fail: {},
105
- },
106
- on: {
107
- SET_CRYPTO: {
108
- target: '.loaded',
109
- actions: 'setCrypto',
110
- },
111
- SET_ADDRESS: {
112
- actions: 'setAddress',
113
- },
114
- SET_AMOUNT: {
115
- target: '.loaded',
116
- actions: ['setAmount', 'clearCalculation'],
117
- },
118
- INPUT_AMOUNT: {
119
- target: '.loaded',
120
- actions: ['inputAmount', 'clearCalculation'],
121
- },
122
- CALCULATE: {
123
- target: '.debouncing',
124
- actions: 'clearCalculation',
125
- },
126
- SET_PROMOTION: {
127
- actions: 'setPromotion',
128
- },
129
- },
130
- },
131
- {
132
- actions: {
133
- setPayment: assign((context, event) => {
134
- const payments = event.data.filter((item) => item.category === context.currentCategory)
135
- const cryptos = payments?.map((value, i) => {
136
- return {
137
- ...value,
138
- label: value?.cryptoOptional[0],
139
- network: value?.networkName[0],
140
- icon: value?.channel,
141
- }
142
- })
143
- return {
144
- cryptos,
145
- selectedCrypto: cryptos[0],
146
- currentPayment: cryptos[0],
147
- }
148
- }),
149
- setCrypto: assign((context, event) => {
150
- const { cryptos } = context
151
- const selectedCrypto = cryptos.find((crypto) => crypto.label === event.data.label)
152
- return {
153
- selectedCrypto: selectedCrypto,
154
- amount: null,
155
- calculation: null,
156
- }
157
- }),
158
- setAmount: assign((context, event) => {
159
- return {
160
- amount: event.data,
161
- }
162
- }),
163
- inputAmount: assign((context, event) => {
164
- return { amount: preciseAdd(`${parseFloat(context.amount || 0)}`, `${parseFloat(event.data)}`) }
165
- }),
166
- setAddress: assign((context, event) => {
167
- return {
168
- sourceAddress: event.data,
169
- }
170
- }),
171
- setCalculation: assign((context, event) => {
172
- // V2接口轉換中回傳的資料結構不同
173
- const { data } = event.data
174
- if (data) {
175
- return {
176
- calculation: data,
177
- }
178
- } else {
179
- return {
180
- calculation: event.data,
181
- }
182
- }
183
- }),
184
- clearCalculation: assign((context, event) => {
185
- return {
186
- calculation: null,
187
- }
188
- }),
189
- setResult: assign((context, event) => {
190
- return {
191
- result: event.data,
192
- }
193
- }),
194
- setPromotion: assign((context, event) => {
195
- const promotion = event.data
196
- return {
197
- promotion,
198
- }
199
- }),
200
- },
201
- guards: {
202
- isCalculable: (context, event) => {
203
- const { selectedCrypto, amount } = context
204
- return selectedCrypto && amount && selectedCrypto?.minimum <= +amount && +amount <= selectedCrypto?.maximum
205
- },
206
- isSubmittable: (context, event) => {
207
- const { selectedCrypto, amount } = context
208
- return selectedCrypto && amount
209
- },
210
- },
211
- services: {
212
- fetchPayments: async (context, event) => {
213
- return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
214
- },
215
- fetchCalculation: async (context, event) => {
216
- const { selectedCrypto, amount, promotion } = context
217
- return await request.send(
218
- payment.getCryptoDepositExpectedResult({
219
- method: selectedCrypto.method,
220
- amount,
221
- cryptoCurrency: selectedCrypto.channel,
222
- promotionsNo: promotion?.activityNo,
223
- })
224
- )
225
- },
226
- submitDeposit: async (context, event) => {
227
- const { selectedCrypto, amount } = context
228
- return await request.send(
229
- payment.submitDepositTransactionCrypto({
230
- method: selectedCrypto.method,
231
- amount: amount,
232
- cryptoCurrency: selectedCrypto.channel,
233
- cryptoNetwork: selectedCrypto.network,
234
- })
235
- )
236
- },
237
- },
238
- }
239
- )
240
- }
241
-
242
- function preciseAdd(a, b) {
243
- let aStr = a.toString()
244
- let bStr = b.toString()
245
-
246
- let aDecimalPlaces = aStr.split('.')[1] ? aStr.split('.')[1].length : 0
247
- let bDecimalPlaces = bStr.split('.')[1] ? bStr.split('.')[1].length : 0
248
-
249
- let factor = Math.pow(10, Math.max(aDecimalPlaces, bDecimalPlaces))
250
-
251
- return (Math.round(a * factor) + Math.round(b * factor)) / factor
252
- }
@@ -1,272 +0,0 @@
1
- // 棄用
2
- import { assign, createMachine } from 'xstate'
3
- import toNumber from 'lodash/toNumber.js'
4
- import payment from '../../api/payment.js'
5
-
6
- // const toNumber = require('lodash/toNumber')
7
-
8
- export default function (request) {
9
- return createMachine(
10
- {
11
- id: 'deposit',
12
- initial: 'loading',
13
- context: {
14
- cryptos: [],
15
- networks: [],
16
- currentCrypto: null,
17
- currentNetwork: null,
18
- currentAmount: null,
19
- calculatedResult: null,
20
- submittedResult: null,
21
- bonus: null,
22
- },
23
- states: {
24
- loading: {
25
- initial: 'bonusStatus',
26
- states: {
27
- bonusStatus: {
28
- invoke: {
29
- src: 'getPaymentInfo',
30
- onDone: {
31
- target: 'fetchingPayments',
32
- actions: 'setBonus',
33
- },
34
- onError: {
35
- target: '#deposit.loaded',
36
- },
37
- },
38
- },
39
- fetchingPayments: {
40
- invoke: {
41
- src: 'fetchPayments',
42
- onDone: {
43
- target: '#deposit.loaded',
44
- actions: 'setCryptos',
45
- },
46
- onError: {
47
- target: '#deposit.loaded',
48
- },
49
- },
50
- },
51
- },
52
- },
53
- loaded: {
54
- on: {
55
- SUBMIT: {
56
- target: 'submitting',
57
- cond: 'isSubmittable',
58
- },
59
- },
60
- },
61
- checking: {
62
- entry: 'clearCalculatedResult',
63
- always: [{ target: 'debouncing', cond: 'isCalculable' }, { target: 'loaded' }],
64
- },
65
- debouncing: {
66
- after: {
67
- 1000: {
68
- target: 'calculating',
69
- },
70
- },
71
- },
72
- calculating: {
73
- invoke: {
74
- src: 'fetchCalculation',
75
- onDone: {
76
- target: 'loaded',
77
- actions: 'setCalculatedResult',
78
- },
79
- onError: {
80
- target: 'loaded',
81
- },
82
- },
83
- },
84
- submitting: {
85
- invoke: {
86
- src: 'submitDeposit',
87
- onDone: {
88
- target: '#deposit.submitted',
89
- actions: 'setSubmittedResult',
90
- },
91
- onError: {
92
- target: 'loaded',
93
- },
94
- },
95
- },
96
- switchingBonus: {
97
- invoke: {
98
- src: 'setBonusSetting',
99
- onDone: {
100
- target: 'checking',
101
- },
102
- onError: {
103
- target: 'loaded',
104
- },
105
- },
106
- },
107
- submitted: {},
108
- },
109
- on: {
110
- SET_CRYPTO: {
111
- target: 'checking',
112
- actions: 'setCrypto',
113
- cond: 'hasCryptoOptions',
114
- },
115
- SET_NETWORK: {
116
- target: 'checking',
117
- actions: 'setNetwork',
118
- cond: 'hasNetworkOptions',
119
- },
120
- SET_AMOUNT: {
121
- target: 'checking',
122
- actions: 'setAmount',
123
- },
124
- TOGGLE_BONUS: {
125
- target: 'switchingBonus',
126
- actions: 'toggleBonus',
127
- },
128
- },
129
- },
130
- {
131
- actions: {
132
- setCryptos: assign((context, event) => {
133
- return {
134
- cryptos: event.data.map((crypto) => ({
135
- ...crypto,
136
- label: crypto.channel,
137
- value: crypto.method,
138
- icon: crypto.channel,
139
- })),
140
- }
141
- }),
142
- setCrypto: assign((context, event) => {
143
- const { cryptos, currentNetwork } = context
144
- const method = cryptos.find((crypto) => crypto.method === event.data.value)
145
- const networks =
146
- method?.networkName.map((value, i) => {
147
- return {
148
- label: method?.networkOptional?.[i],
149
- value,
150
- icon: value,
151
- }
152
- }) || []
153
-
154
- const properties = {
155
- currentCrypto: event.data,
156
- networks,
157
- }
158
-
159
- if (!networks.includes(currentNetwork)) {
160
- properties.currentNetwork = null
161
- properties.currentAmount = null
162
- properties.calculatedResult = null
163
- }
164
-
165
- return properties
166
- }),
167
- setNetwork: assign((context, event) => {
168
- return { currentNetwork: event.data }
169
- }),
170
- setAmount: assign((context, event) => {
171
- const currentAmount = event.data
172
-
173
- const properties = {
174
- currentAmount,
175
- }
176
-
177
- if (!currentAmount) {
178
- properties.calculatedResult = null
179
- }
180
-
181
- return properties
182
- }),
183
- setCalculatedResult: assign((context, event) => {
184
- // V2接口轉換中回傳的資料結構不同
185
- const { data } = event.data
186
- if (data) {
187
- return {
188
- calculatedResult: data,
189
- }
190
- } else {
191
- return {
192
- calculatedResult: event.data,
193
- }
194
- }
195
- }),
196
- setSubmittedResult: assign((context, event) => {
197
- return {
198
- submittedResult: event.data,
199
- }
200
- }),
201
- clearCalculatedResult: assign((context, event) => {
202
- return {
203
- calculatedResult: null,
204
- }
205
- }),
206
- toggleBonus: assign((context, event) => {
207
- const { bonus } = context
208
- return {
209
- bonus: bonus === 1 ? 0 : 1,
210
- }
211
- }),
212
- setBonus: assign((context, event) => {
213
- return {
214
- bonus: event.data,
215
- }
216
- }),
217
- },
218
- guards: {
219
- hasCryptoOptions: (context, evnet) => {
220
- return context.cryptos.length > 0
221
- },
222
- hasNetworkOptions: (context, evnet) => {
223
- return context.networks.length > 0
224
- },
225
- isCalculable: (context, event) => {
226
- const { currentCrypto, currentNetwork, currentAmount } = context
227
- return currentCrypto && currentNetwork && toNumber(currentAmount)
228
- },
229
- isSubmittable: (context, event) => {
230
- return context.calculatedResult
231
- },
232
- isBonusOff: (context, event) => {
233
- return context.bonus !== 1
234
- },
235
- },
236
- services: {
237
- fetchPayments: async (context, event) => {
238
- return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
239
- },
240
- fetchCalculation: async (context, event) => {
241
- const { currentCrypto, currentAmount } = context
242
- return await request.send(
243
- payment.getDepositExpectedResult({
244
- method: currentCrypto.method,
245
- amount: Number(currentAmount),
246
- cryptoCurrency: currentCrypto.channel,
247
- })
248
- )
249
- },
250
- submitDeposit: async (context, event) => {
251
- const { currentCrypto, currentNetwork, calculatedResult } = context
252
- return await request.send(
253
- payment.submitDepositTransactionCrypto({
254
- method: currentCrypto.method,
255
- amount: calculatedResult.actualAmount,
256
- cryptoCurrency: currentCrypto.channel,
257
- cryptoNetwork: currentNetwork.value,
258
- })
259
- )
260
- },
261
- setBonusSetting: async (context, event) => {
262
- const { bonus } = context
263
- return await request.send(payment.setBonusSetting({ bonus }))
264
- },
265
- getPaymentInfo: async (context, event) => {
266
- const { bonus } = await request.send(payment.getPaymentInfo())
267
- return bonus
268
- },
269
- },
270
- }
271
- )
272
- }