@jetthai/cuora 1.1.127 → 1.1.128-dev-2

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 (70) hide show
  1. package/CHANGELOG.md +426 -0
  2. package/package.json +1 -1
  3. package/src/api/activity.js +28 -0
  4. package/src/api/auth.js +6 -0
  5. package/src/api/common.js +2 -1
  6. package/src/api/game.js +5 -4
  7. package/src/api/mailbox.js +9 -5
  8. package/src/api/payment.js +103 -8
  9. package/src/api/user.js +2 -0
  10. package/src/machine/activity/activity.js +56 -16
  11. package/src/machine/activity/activity_cash.js +78 -14
  12. package/src/machine/activity/cash_rain_activity.js +153 -0
  13. package/src/machine/activity/diamond_shop_activity_cash.js +57 -92
  14. package/src/machine/activity/diamond_shop_activity_vn.js +54 -89
  15. package/src/machine/activity/fafafa_activity.js +8 -1
  16. package/src/machine/activity/friend_invite_friends_activity.js +3 -1
  17. package/src/machine/activity/index.js +6 -0
  18. package/src/machine/activity/instant_rebate_activity.js +214 -0
  19. package/src/machine/activity/roulette_activity_v2.js +11 -2
  20. package/src/machine/activity/sign_in_activity.js +20 -13
  21. package/src/machine/activity/vip_card_activity.js +140 -0
  22. package/src/machine/auth.js +54 -5
  23. package/src/machine/bank_binding.js +112 -12
  24. package/src/machine/bank_binding_amb.js +6 -1
  25. package/src/machine/common.js +92 -24
  26. package/src/machine/deposit/amb.js +5 -3
  27. package/src/machine/deposit/crypto.js +14 -10
  28. package/src/machine/deposit/crypto_bank.js +317 -0
  29. package/src/machine/deposit/crypto_bank_cash.js +280 -0
  30. package/src/machine/deposit/crypto_button.js +9 -5
  31. package/src/machine/deposit/crypto_cash.js +2 -5
  32. package/src/machine/deposit/crypto_qrcode.js +147 -0
  33. package/src/machine/deposit/crypto_qrcode_cash.js +131 -0
  34. package/src/machine/deposit/crypto_way.js +220 -0
  35. package/src/machine/deposit/crypto_way_cash.js +242 -0
  36. package/src/machine/deposit/direct.js +2 -11
  37. package/src/machine/deposit/direct_cash.js +6 -26
  38. package/src/machine/deposit/float.js +5 -3
  39. package/src/machine/deposit/index.js +14 -0
  40. package/src/machine/deposit/krway.js +151 -0
  41. package/src/machine/deposit/loadcard_cash.js +6 -27
  42. package/src/machine/deposit/loadcard_vn.js +2 -10
  43. package/src/machine/deposit/manual_cash.js +89 -38
  44. package/src/machine/deposit/manual_vn.js +104 -48
  45. package/src/machine/deposit/qrcode_cash.js +12 -23
  46. package/src/machine/deposit/qrcode_v2.js +3 -8
  47. package/src/machine/deposit/usdt_cash.js +0 -2
  48. package/src/machine/deposit/vpay.js +5 -3
  49. package/src/machine/game_info.js +57 -0
  50. package/src/machine/game_search_cash.js +137 -12
  51. package/src/machine/game_search_v2.js +4 -4
  52. package/src/machine/game_v2_1.js +131 -7
  53. package/src/machine/honor_board_cash.js +63 -0
  54. package/src/machine/inbox.js +259 -34
  55. package/src/machine/index.js +6 -0
  56. package/src/machine/leaderboard.js +31 -8
  57. package/src/machine/reward_cash.js +1 -1
  58. package/src/machine/side_v2.js +1 -1
  59. package/src/machine/user_photo.js +65 -0
  60. package/src/machine/user_sign_up.js +71 -7
  61. package/src/machine/withdraw/index.js +6 -0
  62. package/src/machine/withdraw/withdraw_crypto.js +1 -66
  63. package/src/machine/withdraw/withdraw_crypto2.js +540 -0
  64. package/src/machine/withdraw/withdraw_krway.js +207 -0
  65. package/src/machine/withdraw/withdraw_manual.js +595 -0
  66. package/src/machine/withdraw/withdraw_manual_cash.js +44 -14
  67. package/src/machine/withdraw/withdraw_vn.js +42 -7
  68. package/src/machine/withdraw/withdraw_vn2.js +64 -37
  69. package/src/util/constant.js +18 -0
  70. package/src/util/deviceToken.js +2 -2
@@ -0,0 +1,147 @@
1
+ import { assign, createMachine } from 'xstate'
2
+ import payment from '@jetthai/cuora/src/api/payment.js'
3
+
4
+ export default function (request) {
5
+ return createMachine(
6
+ {
7
+ id: 'crypto_qrcode',
8
+ initial: 'loading',
9
+ context: {
10
+ paymentDetails: [],
11
+ currentCategory: 'cryptoQrcode',
12
+ currentPayment: null,
13
+ cryptos: [],
14
+ selectedCrypto: null,
15
+
16
+ resultMap: {},
17
+ result: {
18
+ action: '',
19
+ cdtime: null,
20
+ accountNumber: '', // crypto address
21
+ currency: '',
22
+ network: '',
23
+ name: '',
24
+ qrcode: '',
25
+ },
26
+ },
27
+ states: {
28
+ loading: {
29
+ invoke: {
30
+ src: 'fetchPaymentDetail',
31
+ onDone: {
32
+ target: 'fetching',
33
+ actions: 'setInitData',
34
+ },
35
+ onError: {
36
+ target: 'fail',
37
+ },
38
+ },
39
+ },
40
+ finding: {
41
+ always: [
42
+ {
43
+ target: 'idle',
44
+ actions: 'setResultFromLocal',
45
+ cond: 'isFound',
46
+ },
47
+ {
48
+ target: 'fetching',
49
+ },
50
+ ],
51
+ },
52
+ fetching: {
53
+ invoke: {
54
+ src: 'submitDeposit',
55
+ onDone: {
56
+ target: 'idle',
57
+ actions: 'setResult',
58
+ },
59
+ onError: {
60
+ target: 'idle',
61
+ },
62
+ },
63
+ },
64
+ idle: {},
65
+ fail: {},
66
+ },
67
+ on: {
68
+ SET_CRYPTO: {
69
+ target: '.finding',
70
+ actions: 'setCrypto',
71
+ },
72
+ },
73
+ },
74
+ {
75
+ actions: {
76
+ setInitData: assign((context, event) => {
77
+ const paymentDetail = event.data || []
78
+ const payments = paymentDetail.filter((item) => item.transferType === 'deposit' && item.category === context.currentCategory)
79
+ const cryptos = payments?.map((value, i) => {
80
+ return {
81
+ ...value,
82
+ label: value?.cryptoOptional[0],
83
+ network: value?.networkName[0],
84
+ icon: value?.channel,
85
+ }
86
+ })
87
+ return {
88
+ cryptos,
89
+ selectedCrypto: cryptos[0],
90
+ currentPayment: cryptos[0],
91
+ }
92
+ }),
93
+ setCrypto: assign((context, event) => {
94
+ const { cryptos } = context
95
+ const selectedCrypto = cryptos.find((crypto) => crypto.label === event.data.label)
96
+ return { selectedCrypto }
97
+ }),
98
+ setResultFromLocal: assign((context, event) => {
99
+ const { resultMap, selectedCrypto } = context
100
+ return { result: resultMap[selectedCrypto.network] }
101
+ }),
102
+ setResult: assign((context, event) => {
103
+ const { resultMap, selectedCrypto } = context
104
+ const { action, cdtime, accountNumber, currency, network, name, qrcode } = event.data
105
+ const result = {
106
+ action,
107
+ cdtime,
108
+ accountNumber,
109
+ currency,
110
+ network,
111
+ name,
112
+ qrcode,
113
+ }
114
+
115
+ return {
116
+ result,
117
+ resultMap: {
118
+ ...resultMap,
119
+ [selectedCrypto.network]: result,
120
+ },
121
+ }
122
+ }),
123
+ },
124
+ guards: {
125
+ isFound: (context, event) => {
126
+ const { resultMap, selectedCrypto } = context
127
+ return resultMap[selectedCrypto.network]
128
+ },
129
+ },
130
+ services: {
131
+ fetchPaymentDetail: async (context, event) => {
132
+ return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
133
+ },
134
+ submitDeposit: async (context, event) => {
135
+ const { currentPayment, selectedCrypto } = context
136
+ return await request.send(
137
+ payment.submitDepositTransactionCrypto({
138
+ method: currentPayment.method,
139
+ cryptoCurrency: currentPayment.channel,
140
+ cryptoNetwork: selectedCrypto.network,
141
+ })
142
+ )
143
+ },
144
+ },
145
+ }
146
+ )
147
+ }
@@ -0,0 +1,131 @@
1
+ import { assign, createMachine } from 'xstate'
2
+ import payment from '@jetthai/cuora/src/api/payment.js'
3
+
4
+ export default function (request) {
5
+ return createMachine(
6
+ {
7
+ id: 'crypto_qrcode_cash',
8
+ initial: 'loading',
9
+ context: {
10
+ currentCategory: 'cryptoQrcode',
11
+ cryptos: [],
12
+ selectedCrypto: null,
13
+ resultMap: {},
14
+ result: {},
15
+ },
16
+ states: {
17
+ loading: {
18
+ invoke: {
19
+ src: 'fetchPaymentDetail',
20
+ onDone: {
21
+ target: 'submitting',
22
+ actions: 'setInitData',
23
+ },
24
+ onError: {
25
+ target: 'fail',
26
+ },
27
+ },
28
+ },
29
+ finding: {
30
+ always: [
31
+ {
32
+ target: 'idle',
33
+ actions: 'setResultFromLocal',
34
+ cond: 'isFound',
35
+ },
36
+ {
37
+ target: 'submitting',
38
+ },
39
+ ],
40
+ },
41
+ submitting: {
42
+ invoke: {
43
+ src: 'submitDeposit',
44
+ onDone: {
45
+ target: 'idle',
46
+ actions: 'setResult',
47
+ },
48
+ onError: {
49
+ target: 'idle',
50
+ },
51
+ },
52
+ },
53
+ idle: {},
54
+ fail: {},
55
+ },
56
+ on: {
57
+ SET_CRYPTO: {
58
+ target: '.finding',
59
+ actions: 'setCrypto',
60
+ },
61
+ SET_NETWORK: {
62
+ target: '.finding',
63
+ actions: 'setNetwork',
64
+ },
65
+ },
66
+ },
67
+ {
68
+ actions: {
69
+ setInitData: assign((context, event) => {
70
+ const paymentDetail = event.data || []
71
+ const payments = paymentDetail.filter((item) => item.category === context.currentCategory)
72
+ const cryptos = payments.map((payment) => ({
73
+ ...payment,
74
+ label: payment.cryptoOptional?.[0],
75
+ network: payment.networkName?.[0],
76
+ value: payment.method,
77
+ icon: payment.channel,
78
+ }))
79
+
80
+ return {
81
+ cryptos,
82
+ selectedCrypto: cryptos[0],
83
+ }
84
+ }),
85
+ setCrypto: assign((context, event) => {
86
+ const { cryptos } = context
87
+ const selectedCrypto = cryptos.find((crypto) => crypto.label === event.data.label)
88
+ return { selectedCrypto }
89
+ }),
90
+ setResultFromLocal: assign((context, event) => {
91
+ const { resultMap, selectedCrypto } = context
92
+ return { result: resultMap[`${selectedCrypto.channel}_${selectedCrypto.network}`] }
93
+ }),
94
+ setResult: assign((context, event) => {
95
+ const { resultMap, selectedCrypto } = context
96
+ const { accountNumber, currency, network, qrcode, forexRate } = event.data
97
+ const result = { accountNumber, currency, network, qrcode, forexRate }
98
+
99
+ return {
100
+ result,
101
+ resultMap: {
102
+ ...resultMap,
103
+ [`${selectedCrypto.channel}_${selectedCrypto.network}`]: result,
104
+ },
105
+ }
106
+ }),
107
+ },
108
+ guards: {
109
+ isFound: (context, event) => {
110
+ const { resultMap, selectedCrypto } = context
111
+ return resultMap[`${selectedCrypto.channel}_${selectedCrypto.network}`]
112
+ },
113
+ },
114
+ services: {
115
+ fetchPaymentDetail: async (context, event) => {
116
+ return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
117
+ },
118
+ submitDeposit: async (context, event) => {
119
+ const { selectedCrypto } = context
120
+ return await request.send(
121
+ payment.submitDepositTransactionCrypto({
122
+ method: selectedCrypto.method,
123
+ cryptoCurrency: selectedCrypto.channel,
124
+ cryptoNetwork: selectedCrypto.network,
125
+ })
126
+ )
127
+ },
128
+ },
129
+ }
130
+ )
131
+ }
@@ -0,0 +1,220 @@
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: 'loaded',
95
+ },
96
+ },
97
+ },
98
+ submitted: {},
99
+ fail: {},
100
+ },
101
+ on: {
102
+ SET_CRYPTO: {
103
+ target: '.loaded',
104
+ actions: 'setCrypto',
105
+ },
106
+ SET_ADDRESS: {
107
+ actions: 'setAddress',
108
+ },
109
+ SET_AMOUNT: {
110
+ target: '.loaded',
111
+ actions: ['setAmount', 'clearCalculation'],
112
+ },
113
+ CALCULATE: {
114
+ target: '.debouncing',
115
+ actions: 'clearCalculation',
116
+ },
117
+ SET_PROMOTION: {
118
+ actions: 'setPromotion',
119
+ },
120
+ },
121
+ },
122
+ {
123
+ actions: {
124
+ setPayment: assign((context, event) => {
125
+ const payments = event.data.filter((item) => item.category === context.currentCategory)
126
+ const cryptos = payments?.map((value, i) => {
127
+ return {
128
+ ...value,
129
+ label: value?.cryptoOptional[0],
130
+ network: value?.networkName[0],
131
+ icon: value?.channel,
132
+ }
133
+ })
134
+ return {
135
+ cryptos,
136
+ selectedCrypto: cryptos[0],
137
+ currentPayment: cryptos[0],
138
+ }
139
+ }),
140
+ setCrypto: assign((context, event) => {
141
+ const { cryptos } = context
142
+ const selectedCrypto = cryptos.find((crypto) => crypto.label === event.data.label)
143
+ return {
144
+ selectedCrypto: selectedCrypto,
145
+ amount: null,
146
+ calculation: null,
147
+ }
148
+ }),
149
+ setAmount: assign((context, event) => {
150
+ return {
151
+ amount: event.data,
152
+ }
153
+ }),
154
+ setAddress: assign((context, event) => {
155
+ return {
156
+ sourceAddress: event.data,
157
+ }
158
+ }),
159
+ setCalculation: assign((context, event) => {
160
+ return {
161
+ calculation: event.data,
162
+ }
163
+ }),
164
+ clearCalculation: assign((context, event) => {
165
+ return {
166
+ calculation: null,
167
+ }
168
+ }),
169
+ setResult: assign((context, event) => {
170
+ return {
171
+ result: event.data,
172
+ }
173
+ }),
174
+ setPromotion: assign((context, event) => {
175
+ const promotion = event.data
176
+ return {
177
+ promotion,
178
+ }
179
+ }),
180
+ },
181
+ guards: {
182
+ isCalculable: (context, event) => {
183
+ const { selectedCrypto, amount } = context
184
+ return selectedCrypto && amount && selectedCrypto?.minimum <= +amount && +amount <= selectedCrypto?.maximum
185
+ },
186
+ isSubmittable: (context, event) => {
187
+ const { selectedCrypto, amount } = context
188
+ return selectedCrypto && amount
189
+ },
190
+ },
191
+ services: {
192
+ fetchPayments: async (context, event) => {
193
+ return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
194
+ },
195
+ fetchCalculation: async (context, event) => {
196
+ const { selectedCrypto, amount, promotion } = context
197
+ return await request.send(
198
+ payment.getCryptoDepositExpectedResult({
199
+ method: selectedCrypto.method,
200
+ amount,
201
+ cryptoCurrency: selectedCrypto.channel,
202
+ promotionsNo: promotion?.activityNo,
203
+ })
204
+ )
205
+ },
206
+ submitDeposit: async (context, event) => {
207
+ const { selectedCrypto, amount } = context
208
+ return await request.send(
209
+ payment.submitDepositTransactionCrypto({
210
+ method: selectedCrypto.method,
211
+ amount: amount,
212
+ cryptoCurrency: selectedCrypto.channel,
213
+ cryptoNetwork: selectedCrypto.network,
214
+ })
215
+ )
216
+ },
217
+ },
218
+ }
219
+ )
220
+ }