@jetthai/cuora 1.1.10 → 1.1.11

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 (40) hide show
  1. package/.husky/pre-commit +4 -0
  2. package/.prettierignore +1 -0
  3. package/CHANGELOG.md +7 -2
  4. package/README.md +6 -0
  5. package/dist/bundle.mjs +2355 -3495
  6. package/package.json +6 -3
  7. package/rollup.config.js +3 -7
  8. package/src/api/activity.js +1 -1
  9. package/src/api/auth.js +4 -2
  10. package/src/api/game.js +14 -2
  11. package/src/api/payment.js +25 -5
  12. package/src/machine/activity/activity.js +7 -7
  13. package/src/machine/activity/affiliate_invite_friends_activity.js +16 -19
  14. package/src/machine/activity/invite_friends_activity.js +1 -1
  15. package/src/machine/activity/sign_in_activity.js +1 -1
  16. package/src/machine/bank_binding_amb.js +141 -0
  17. package/src/machine/common.js +3 -4
  18. package/src/machine/deposit/amb.js +90 -0
  19. package/src/machine/deposit/crypto.js +1 -1
  20. package/src/machine/deposit/crypto_button.js +24 -22
  21. package/src/machine/deposit/deposit_fc.js +8 -5
  22. package/src/machine/deposit/float.js +295 -0
  23. package/src/machine/deposit/index.js +16 -1
  24. package/src/machine/deposit/loadcard_vn.js +1 -1
  25. package/src/machine/deposit/manual_vn.js +5 -11
  26. package/src/machine/deposit/qrcode_v2.js +18 -14
  27. package/src/machine/deposit/qrcode_vn.js +1 -1
  28. package/src/machine/deposit/vpay.js +292 -0
  29. package/src/machine/game_favorite_v2.js +1 -1
  30. package/src/machine/game_search_v2.js +40 -14
  31. package/src/machine/game_v2.js +6 -9
  32. package/src/machine/index.js +4 -0
  33. package/src/machine/reward.js +2 -2
  34. package/src/machine/side_v2.js +12 -12
  35. package/src/machine/user_sign_up.js +4 -5
  36. package/src/machine/withdraw_amb.js +373 -0
  37. package/src/machine/withdraw_crypto.js +37 -25
  38. package/src/machine/withdraw_fc.js +1 -1
  39. package/src/util/constant.js +1 -1
  40. package/src/util/storage.js +22 -22
@@ -26,7 +26,7 @@ export default function (request) {
26
26
  calculation: null,
27
27
  result: null,
28
28
 
29
- grandTotalEnable: 1
29
+ grandTotalEnable: 1,
30
30
  },
31
31
  states: {
32
32
  loading: {
@@ -57,7 +57,7 @@ export default function (request) {
57
57
  },
58
58
  CONFIRM: {
59
59
  target: 'selecting',
60
- cond: 'isConfirmable'
60
+ cond: 'isConfirmable',
61
61
  },
62
62
  },
63
63
  },
@@ -70,19 +70,20 @@ export default function (request) {
70
70
  target: 'debouncing',
71
71
  actions: 'addAmount',
72
72
  cond: (context, event) => context.grandTotalEnable === 1,
73
- }, {
73
+ },
74
+ {
74
75
  target: 'debouncing',
75
- actions: 'setAmount'
76
- }
76
+ actions: 'setAmount',
77
+ },
77
78
  ],
78
79
  KEY_IN: {
79
80
  target: 'debouncing',
80
- actions: 'setAmount'
81
+ actions: 'setAmount',
81
82
  },
82
83
  BACK: {
83
- target: 'loaded'
84
- }
85
- }
84
+ target: 'loaded',
85
+ },
86
+ },
86
87
  },
87
88
  debouncing: {
88
89
  on: {
@@ -91,10 +92,11 @@ export default function (request) {
91
92
  target: 'debouncing',
92
93
  actions: 'addAmount',
93
94
  cond: (context, event) => context.grandTotalEnable === 1,
94
- }, {
95
+ },
96
+ {
95
97
  target: 'debouncing',
96
- actions: 'setAmount'
97
- }
98
+ actions: 'setAmount',
99
+ },
98
100
  ],
99
101
  KEY_IN: {
100
102
  target: 'debouncing',
@@ -116,7 +118,7 @@ export default function (request) {
116
118
  },
117
119
  onError: {
118
120
  target: 'selecting',
119
- actions: 'reset'
121
+ actions: 'reset',
120
122
  },
121
123
  },
122
124
  },
@@ -127,10 +129,11 @@ export default function (request) {
127
129
  target: 'debouncing',
128
130
  actions: 'addAmount',
129
131
  cond: (context, event) => context.grandTotalEnable === 1,
130
- }, {
132
+ },
133
+ {
131
134
  target: 'debouncing',
132
- actions: 'setAmount'
133
- }
135
+ actions: 'setAmount',
136
+ },
134
137
  ],
135
138
  KEY_IN: {
136
139
  target: 'debouncing',
@@ -138,7 +141,7 @@ export default function (request) {
138
141
  },
139
142
  SUBMIT: {
140
143
  target: 'submitting',
141
- cond: 'isSubmittable'
144
+ cond: 'isSubmittable',
142
145
  },
143
146
  CLEAR_CALCULATION: {
144
147
  target: 'debouncing',
@@ -162,8 +165,7 @@ export default function (request) {
162
165
  },
163
166
  },
164
167
  },
165
- submitted: {
166
- },
168
+ submitted: {},
167
169
  },
168
170
  },
169
171
  {
@@ -196,7 +198,7 @@ export default function (request) {
196
198
  selectedNetwork: defaultNetworks[0],
197
199
  grandTotalEnable: cryptos[0].grandTotalEnable,
198
200
  currentPayment,
199
- options
201
+ options,
200
202
  }
201
203
  }),
202
204
  setChannel: assign((context, event) => {
@@ -219,7 +221,7 @@ export default function (request) {
219
221
  selectedAmount: null,
220
222
  calculation: null,
221
223
  grandTotalEnable: selectedCrypto.grandTotalEnable,
222
- options
224
+ options,
223
225
  }
224
226
  }),
225
227
  setCrypto: assign((context, event) => {
@@ -304,7 +306,7 @@ export default function (request) {
304
306
  submitDeposit: async (context, event) => {
305
307
  const { selectedCrypto, selectedNetwork, calculation, sourceAddress } = context
306
308
  return await request.send(
307
- payment.submitDepositTransaction({
309
+ payment.submitDepositTransactionCrypto({
308
310
  method: selectedCrypto.method,
309
311
  amount: calculation.actualAmount,
310
312
  cryptoCurrency: selectedCrypto.channel,
@@ -59,9 +59,7 @@ export default function (request) {
59
59
  },
60
60
  checking: {
61
61
  entry: 'clearCalculatedResult',
62
- always: [
63
- { target: 'debouncing', cond: 'isCalculable' },
64
- { target: 'loaded'}]
62
+ always: [{ target: 'debouncing', cond: 'isCalculable' }, { target: 'loaded' }],
65
63
  },
66
64
  debouncing: {
67
65
  after: {
@@ -132,7 +130,12 @@ export default function (request) {
132
130
  actions: {
133
131
  setCryptos: assign((context, event) => {
134
132
  return {
135
- cryptos: event.data.map((crypto) => ({ ...crypto, label: crypto.channel, value: crypto.method, icon: crypto.channel })),
133
+ cryptos: event.data.map((crypto) => ({
134
+ ...crypto,
135
+ label: crypto.channel,
136
+ value: crypto.method,
137
+ icon: crypto.channel,
138
+ })),
136
139
  }
137
140
  }),
138
141
  setCrypto: assign((context, event) => {
@@ -238,7 +241,7 @@ export default function (request) {
238
241
  submitDeposit: async (context, event) => {
239
242
  const { currentCrypto, currentNetwork, calculatedResult } = context
240
243
  return await request.send(
241
- payment.submitDepositTransaction({
244
+ payment.submitDepositTransactionCrypto({
242
245
  method: currentCrypto.method,
243
246
  amount: calculatedResult.actualAmount,
244
247
  cryptoCurrency: currentCrypto.channel,
@@ -0,0 +1,295 @@
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: 'float',
8
+ initial: 'loading',
9
+ context: {
10
+ method: 'amb_float',
11
+ userAccount: {},
12
+ amount: 0,
13
+
14
+ bankList: [],
15
+ options: [],
16
+ minimum: 0,
17
+ maximum: 0,
18
+
19
+ calculation: null,
20
+
21
+ houseAccountName: null,
22
+ houseAccountNumber: null,
23
+ houseBankName: null,
24
+ calculatedAmount: 0,
25
+
26
+ grandTotalEnable: 1,
27
+ ttl: 120,
28
+ },
29
+ states: {
30
+ loading: {
31
+ initial: 'checkingUserAccount',
32
+ states: {
33
+ checkingUserAccount: {
34
+ invoke: {
35
+ src: 'fetchPaymentInfo',
36
+ onDone: [
37
+ {
38
+ target: 'initializing',
39
+ actions: 'setUserAccount',
40
+ cond: 'hasUserAccount',
41
+ },
42
+ { target: '#float.accountUnbound' },
43
+ ],
44
+ onError: {
45
+ target: '#float.unavailable',
46
+ },
47
+ },
48
+ },
49
+ initializing: {
50
+ invoke: {
51
+ src: 'initialize',
52
+ onDone: { target: '#float.loaded', actions: 'setInitialization' },
53
+ onError: {
54
+ target: '#float.unavailable',
55
+ },
56
+ },
57
+ },
58
+ },
59
+ },
60
+ loaded: {
61
+ entry: 'reset',
62
+ on: {
63
+ SELECT_AMOUNT: [
64
+ {
65
+ target: 'debouncing',
66
+ actions: 'addAmount',
67
+ cond: (context, event) => context.grandTotalEnable === 1,
68
+ },
69
+ {
70
+ target: 'debouncing',
71
+ actions: 'setAmount',
72
+ },
73
+ ],
74
+ KEY_IN: {
75
+ target: 'calculating',
76
+ actions: 'setAmount',
77
+ },
78
+ },
79
+ },
80
+ debouncing: {
81
+ on: {
82
+ SELECT_AMOUNT: [
83
+ {
84
+ target: 'debouncing',
85
+ actions: 'addAmount',
86
+ cond: (context, event) => context.grandTotalEnable === 1,
87
+ },
88
+ {
89
+ target: 'debouncing',
90
+ actions: 'setAmount',
91
+ },
92
+ ],
93
+ KEY_IN: {
94
+ target: 'debouncing',
95
+ actions: 'setAmount',
96
+ },
97
+ BACK: {
98
+ target: 'loaded',
99
+ },
100
+ },
101
+ after: {
102
+ 1000: {
103
+ target: 'calculating',
104
+ },
105
+ },
106
+ },
107
+ calculable: {
108
+ entry: 'clearCalculation',
109
+ on: {
110
+ SELECT_AMOUNT: [
111
+ {
112
+ target: 'debouncing',
113
+ actions: 'addAmount',
114
+ cond: (context, event) => context.grandTotalEnable === 1,
115
+ },
116
+ {
117
+ target: 'debouncing',
118
+ actions: 'setAmount',
119
+ },
120
+ ],
121
+ KEY_IN: {
122
+ target: 'debouncing',
123
+ actions: 'setAmount',
124
+ },
125
+ CALCULATE: {
126
+ target: 'debouncing',
127
+ },
128
+ BACK: {
129
+ target: 'loaded',
130
+ },
131
+ },
132
+ },
133
+ calculating: {
134
+ invoke: {
135
+ src: 'fetchCalculation',
136
+ onDone: {
137
+ target: 'calculated',
138
+ actions: 'setCalculation',
139
+ },
140
+ onError: {
141
+ target: 'calculable',
142
+ },
143
+ },
144
+ },
145
+ calculated: {
146
+ on: {
147
+ SELECT_AMOUNT: [
148
+ {
149
+ target: 'debouncing',
150
+ actions: 'addAmount',
151
+ cond: (context, event) => context.grandTotalEnable === 1,
152
+ },
153
+ {
154
+ target: 'debouncing',
155
+ actions: 'setAmount',
156
+ },
157
+ ],
158
+ KEY_IN: {
159
+ target: 'debouncing',
160
+ actions: 'setAmount',
161
+ },
162
+ CONFIRM: {
163
+ target: 'submitting',
164
+ },
165
+ BACK: {
166
+ target: 'loaded',
167
+ },
168
+ CLEAR_CALCULATION: {
169
+ target: 'debouncing',
170
+ actions: 'clearCalculation',
171
+ },
172
+ },
173
+ },
174
+ submitting: {
175
+ invoke: {
176
+ src: 'submitDeposit',
177
+ onDone: { target: 'countdown', actions: 'setHouseBank' },
178
+ onError: {
179
+ target: 'calculated',
180
+ },
181
+ },
182
+ },
183
+ countdown: {
184
+ after: {
185
+ 1000: [
186
+ {
187
+ target: 'countdown',
188
+ actions: 'decreaseTtl',
189
+ cond: (context) => context.ttl > 0,
190
+ },
191
+ {
192
+ target: 'loaded',
193
+ },
194
+ ],
195
+ },
196
+ },
197
+ accountUnbound: {},
198
+ unavailable: {},
199
+ },
200
+ },
201
+ {
202
+ actions: {
203
+ setUserAccount: assign((context, event) => {
204
+ return {
205
+ userAccount: event.data.bankInfo?.[0],
206
+ }
207
+ }),
208
+ setHouseBank: assign((context, event) => {
209
+ const { accountName, accountNumber, bankName, amount } = event.data
210
+ return {
211
+ houseAccountName: accountName,
212
+ houseAccountNumber: accountNumber,
213
+ houseBankName: bankName,
214
+ calculatedAmount: amount,
215
+ }
216
+ }),
217
+ setInitialization: assign((context, event) => {
218
+ const { housePayment, bankList } = event.data
219
+ const { optional, minimum, maximum, grandTotalEnable } = housePayment
220
+ return {
221
+ options: optional,
222
+ minimum,
223
+ maximum,
224
+ bankList,
225
+ grandTotalEnable,
226
+ }
227
+ }),
228
+ addAmount: assign((context, event) => {
229
+ const { amount, maximum } = context
230
+ return {
231
+ amount: Math.min(amount + event.data, maximum),
232
+ }
233
+ }),
234
+ setAmount: assign((context, event) => {
235
+ return { amount: event.data }
236
+ }),
237
+ clear: assign((context, event) => {
238
+ return {
239
+ amount: 0,
240
+ }
241
+ }),
242
+ setCalculation: assign((context, event) => {
243
+ return {
244
+ calculation: event.data,
245
+ }
246
+ }),
247
+ clearCalculation: assign((context, event) => {
248
+ return {
249
+ calculation: null,
250
+ }
251
+ }),
252
+ decreaseTtl: assign((context, evnet) => {
253
+ const ms = context.ttl
254
+ return {
255
+ ttl: Math.max(ms - 1, 0),
256
+ }
257
+ }),
258
+ },
259
+ guards: {
260
+ hasUserAccount: (context, event) => {
261
+ return event.data.bankInfo?.[0]
262
+ },
263
+ },
264
+ services: {
265
+ fetchPaymentInfo: async (context, event) => {
266
+ return await request.send(payment.getPaymentInfo())
267
+ },
268
+ initialize: async (context, event) => {
269
+ const [payments, bankList] = await Promise.all([
270
+ request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' })),
271
+ request.send(payment.getBankList('amb')),
272
+ ])
273
+ return { housePayment: payments.find((payment) => payment.method === context.method), bankList }
274
+ },
275
+ submitDeposit: async (context, event) => {
276
+ return await request.send(
277
+ payment.submitDepositTransaction({
278
+ method: context.method,
279
+ amount: context.amount,
280
+ })
281
+ )
282
+ },
283
+ fetchCalculation: async (context, event) => {
284
+ const { currentMethod, selectedAmount } = context
285
+ return await request.send(
286
+ payment.getDepositExpectedResult({
287
+ method: context.method,
288
+ amount: context.amount,
289
+ })
290
+ )
291
+ },
292
+ },
293
+ }
294
+ )
295
+ }
@@ -6,5 +6,20 @@ import deposit_fc from './deposit_fc.js'
6
6
  import crypto from './crypto.js'
7
7
  import crypto_button from './crypto_button.js'
8
8
  import direct from './direct.js'
9
+ import amb from './amb.js'
10
+ import float from './float.js'
11
+ import vpay from './vpay.js'
9
12
 
10
- export default { manual_vn, loadcard_vn, qrcode_vn, qrcode_v2, deposit_fc, crypto, crypto_button, direct }
13
+ export default {
14
+ manual_vn,
15
+ loadcard_vn,
16
+ qrcode_vn,
17
+ qrcode_v2,
18
+ deposit_fc,
19
+ crypto,
20
+ crypto_button,
21
+ direct,
22
+ amb,
23
+ float,
24
+ vpay,
25
+ }
@@ -165,7 +165,7 @@ export default function (request) {
165
165
  cards,
166
166
  selectedCard: cards[0],
167
167
  currentMethod: cards[0].method,
168
- options: cards[0].optional
168
+ options: cards[0].optional,
169
169
  }
170
170
  }),
171
171
  setCard: assign((context, event) => {
@@ -68,7 +68,7 @@ export default function (request) {
68
68
  step1: {
69
69
  initial: 'idle',
70
70
  states: {
71
- idle: { },
71
+ idle: {},
72
72
  calculating: {
73
73
  invoke: {
74
74
  src: 'fetchCalculation',
@@ -83,10 +83,7 @@ export default function (request) {
83
83
  },
84
84
  debouncing: {
85
85
  after: {
86
- 1000: [
87
- { target: 'calculating', cond: 'isCalculable'},
88
- { target: 'idle'},
89
- ]
86
+ 1000: [{ target: 'calculating', cond: 'isCalculable' }, { target: 'idle' }],
90
87
  },
91
88
  },
92
89
  },
@@ -113,7 +110,7 @@ export default function (request) {
113
110
  step2: {
114
111
  initial: 'idle',
115
112
  states: {
116
- idle: { },
113
+ idle: {},
117
114
  calculating: {
118
115
  invoke: {
119
116
  src: 'fetchCalculation',
@@ -128,10 +125,7 @@ export default function (request) {
128
125
  },
129
126
  debouncing: {
130
127
  after: {
131
- 1000: [
132
- { target: 'calculating', cond: 'isCalculable'},
133
- { target: 'idle'},
134
- ]
128
+ 1000: [{ target: 'calculating', cond: 'isCalculable' }, { target: 'idle' }],
135
129
  },
136
130
  },
137
131
  submitting: {
@@ -152,7 +146,7 @@ export default function (request) {
152
146
  actions: ['setAmount', 'clearCalculation'],
153
147
  },
154
148
  CALCULATE: {
155
- target: '.debouncing',
149
+ target: '.debouncing',
156
150
  },
157
151
  SELECT_HOUSE_BANK: {
158
152
  actions: 'setHouseBank',
@@ -21,7 +21,7 @@ export default function (request) {
21
21
 
22
22
  result: null,
23
23
 
24
- grandTotalEnable: 1
24
+ grandTotalEnable: 1,
25
25
  },
26
26
  states: {
27
27
  loading: {
@@ -47,10 +47,11 @@ export default function (request) {
47
47
  target: 'debouncing',
48
48
  actions: 'addAmount',
49
49
  cond: (context, event) => context.grandTotalEnable === 1,
50
- }, {
50
+ },
51
+ {
51
52
  target: 'debouncing',
52
- actions: 'setAmount'
53
- }
53
+ actions: 'setAmount',
54
+ },
54
55
  ],
55
56
  KEY_IN: {
56
57
  target: 'calculating',
@@ -65,10 +66,11 @@ export default function (request) {
65
66
  target: 'debouncing',
66
67
  actions: 'addAmount',
67
68
  cond: (context, event) => context.grandTotalEnable === 1,
68
- }, {
69
+ },
70
+ {
69
71
  target: 'debouncing',
70
- actions: 'setAmount'
71
- }
72
+ actions: 'setAmount',
73
+ },
72
74
  ],
73
75
  KEY_IN: {
74
76
  target: 'debouncing',
@@ -93,10 +95,11 @@ export default function (request) {
93
95
  target: 'debouncing',
94
96
  actions: 'addAmount',
95
97
  cond: (context, event) => context.grandTotalEnable === 1,
96
- }, {
98
+ },
99
+ {
97
100
  target: 'debouncing',
98
- actions: 'setAmount'
99
- }
101
+ actions: 'setAmount',
102
+ },
100
103
  ],
101
104
  KEY_IN: {
102
105
  target: 'debouncing',
@@ -129,10 +132,11 @@ export default function (request) {
129
132
  target: 'debouncing',
130
133
  actions: 'addAmount',
131
134
  cond: (context, event) => context.grandTotalEnable === 1,
132
- }, {
135
+ },
136
+ {
133
137
  target: 'debouncing',
134
- actions: 'setAmount'
135
- }
138
+ actions: 'setAmount',
139
+ },
136
140
  ],
137
141
  KEY_IN: {
138
142
  target: 'debouncing',
@@ -239,7 +243,7 @@ export default function (request) {
239
243
  submitDeposit: async (context, event) => {
240
244
  const { currentMethod, selectedAmount } = context
241
245
  return await request.send(
242
- payment.submitDepositTransactionQrcode({
246
+ payment.submitDepositTransaction({
243
247
  method: currentMethod,
244
248
  amount: selectedAmount,
245
249
  })
@@ -194,7 +194,7 @@ export default function (request) {
194
194
  submitDeposit: async (context, event) => {
195
195
  const { currentMethod, selectedAmount } = context
196
196
  return await request.send(
197
- payment.submitDepositTransactionQrcode({
197
+ payment.submitDepositTransaction({
198
198
  method: currentMethod,
199
199
  amount: selectedAmount,
200
200
  })