@jetthai/cuora 1.1.131 → 1.1.132

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/CHANGELOG.md CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
- ### [1.1.131](https://github.com/jetthai/cuora-module/compare/v1.1.130...v1.1.131) (2023-07-02)
5
+ ### [1.1.132](https://github.com/jetthai/cuora-module/compare/v1.1.131...v1.1.132) (2023-07-05)
6
+
7
+ ### [1.1.131](https://github.com/jetthai/cuora-module/compare/v1.1.130...v1.1.131) (2023-07-05)
6
8
 
7
9
  ### [1.1.130](https://github.com/jetthai/cuora-module/compare/v1.1.129...v1.1.130) (2023-06-28)
8
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.131",
3
+ "version": "1.1.132",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -88,10 +88,6 @@ export default function (request) {
88
88
  CALCULATE: {
89
89
  target: 'debouncing',
90
90
  },
91
- CONFIRM: {
92
- target: 'pending',
93
- cond: (context, event) => !!context.calculation,
94
- },
95
91
  SUBMIT: [
96
92
  {
97
93
  target: 'pending',
@@ -2,6 +2,7 @@ import withdraw_fc from './withdraw_fc.js'
2
2
  import withdraw_vn from './withdraw_vn.js'
3
3
  import withdraw_vn2 from './withdraw_vn2.js'
4
4
  import withdraw_crypto from './withdraw_crypto.js'
5
+ import withdraw_crypto2 from './withdraw_crypto2.js'
5
6
  import withdraw_amb from './withdraw_amb.js'
6
7
  import withdraw_crypto_cash from './withdraw_crypto_cash.js'
7
8
  import withdraw_manual_cash from './withdraw_manual_cash.js'
@@ -11,6 +12,7 @@ export default {
11
12
  withdraw_vn,
12
13
  withdraw_vn2,
13
14
  withdraw_crypto,
15
+ withdraw_crypto2,
14
16
  withdraw_amb,
15
17
  withdraw_crypto_cash,
16
18
  withdraw_manual_cash,
@@ -23,7 +23,6 @@ export default function (request) {
23
23
  targetWithdrawLimit: null,
24
24
 
25
25
  maxWithdrawAmount: null,
26
- availableWithdrawAmount: null,
27
26
  enableWithdraw: false,
28
27
  withdrawRules: [],
29
28
 
@@ -62,18 +61,6 @@ export default function (request) {
62
61
  free: {
63
62
  initial: 'checking',
64
63
  states: {
65
- // loading: {
66
- // invoke: {
67
- // src: 'fetchWithdrawRules',
68
- // onDone: {
69
- // target: 'checking',
70
- // actions: 'updateWithdrawCondition',
71
- // },
72
- // onError: {
73
- // target: 'notConvertible',
74
- // },
75
- // },
76
- // },
77
64
  checking: {
78
65
  always: [{ target: 'convertible', cond: 'isConvertible' }, { target: 'notConvertible' }],
79
66
  },
@@ -324,11 +311,6 @@ export default function (request) {
324
311
  }) || [],
325
312
  }
326
313
  }),
327
- setPaymentData: assign((context, event) => {
328
- return {
329
- paymentDetail: event.data.paymentDetail,
330
- }
331
- }),
332
314
  preset: assign((context, event) => {
333
315
  const { userInfo, siteConfig } = event.data
334
316
  const { withdraw_limit, target_withdraw_limit } = userInfo || {}
@@ -345,12 +327,9 @@ export default function (request) {
345
327
  }
346
328
  }),
347
329
  updateWithdrawCondition: assign((context, event) => {
348
- const { differAmountLimit, enableWithdraw, enableWithdrawAmount, maxWithdrawStatus, maximumWithdrawAmount, minimumWithdrawAmount } =
349
- event.data?.withdrawRule
350
-
330
+ const { enableWithdraw, enableWithdrawAmount } = event.data?.withdrawRule
351
331
  const withdrawRules = event.data?.withdrawRule?.rules || []
352
332
  const rules = withdrawRules.filter((rule) => rule.maxWithdrawAmount > 0)
353
-
354
333
  const { balance } = context
355
334
  const lastMatchedIndex = findLastIndex(rules, (rule) => balance >= rule.greaterEqualThen)
356
335
 
@@ -371,32 +350,6 @@ export default function (request) {
371
350
  enableWithdraw,
372
351
  withdrawRules,
373
352
  }
374
-
375
- // const rules = event.data.rules.filter((rule) => rule.maxWithdrawAmount > 0)
376
- //
377
- // const { balance, withdrawLimit } = context
378
- // const lastMatchedIndex = findLastIndex(rules, (rule) => balance >= rule.greaterEqualThen)
379
- //
380
- // let maxWithdrawAmount = 0,
381
- // availableWithdrawAmount = 0
382
- //
383
- // if (lastMatchedIndex > -1) {
384
- // rules[lastMatchedIndex].match = true
385
- // maxWithdrawAmount = rules[lastMatchedIndex].maxWithdrawAmount
386
- //
387
- // if (withdrawLimit === 0) {
388
- // availableWithdrawAmount = Math.min(balance, maxWithdrawAmount)
389
- // }
390
- // } else if (rules.length > 0) {
391
- // maxWithdrawAmount = rules[0].maxWithdrawAmount
392
- // } else {
393
- // maxWithdrawAmount = balance
394
- // }
395
- //
396
- // return {
397
- // maxWithdrawAmount,
398
- // availableWithdrawAmount,
399
- // }
400
353
  }),
401
354
  setNetwork: assign((context, event) => {
402
355
  return {
@@ -423,12 +376,6 @@ export default function (request) {
423
376
  charge: null,
424
377
  }
425
378
  }),
426
- setTransaction: assign((context, event) => {
427
- const { realAmount } = event.data
428
- return {
429
- realAmount,
430
- }
431
- }),
432
379
  setOtp: assign((context, event) => {
433
380
  const { requestId, status, target, ttl } = event.data
434
381
  return {
@@ -468,11 +415,6 @@ export default function (request) {
468
415
  haveProcessing: (context, event) => {
469
416
  return (context.paymentDetail?.[0]?.processing || []).length > 0
470
417
  },
471
- isWithdrawDisable: (context, event) => {
472
- const { siteConfig } = context
473
- const methods = siteConfig?.paymentMethods?.withdraw || []
474
- return methods.length === 0
475
- },
476
418
  isSubmittable: (context, event) => {
477
419
  const { selectedNetwork, address, amount, charge } = context
478
420
  return selectedNetwork && address && amount && charge
@@ -505,13 +447,6 @@ export default function (request) {
505
447
  const siteConfig = JSON.parse(window.atob(config))
506
448
  return { siteConfig, userInfo, paymentDetail, withdrawRule }
507
449
  },
508
- fetchPaymentData: async (context, event) => {
509
- const paymentDetail = await request.send(payment.getPaymentDetail({ transferType: 'WITHDRAW' }))
510
- return { paymentDetail }
511
- },
512
- fetchWithdrawRules: async (context, event) => {
513
- return await request.send(payment.getCurrentWithdrawRule())
514
- },
515
450
  submitWithdraw: async (context, event) => {
516
451
  const { crypto, selectedNetwork, address, amount } = context
517
452
  return await request.send(
@@ -0,0 +1,540 @@
1
+ import { assign, createMachine } from 'xstate'
2
+ import findLastIndex from 'lodash/findLastIndex.js'
3
+ import payment from '../../api/payment.js'
4
+ import common from '../../api/common.js'
5
+ import user from '../../api/user.js'
6
+ import api from '../../api/payment.js'
7
+
8
+ export default function (request) {
9
+ const { appSecret } = request.config
10
+ return createMachine(
11
+ {
12
+ id: 'withdraw_crypto2',
13
+ initial: 'loading',
14
+ context: {
15
+ mode: null,
16
+ siteConfig: null,
17
+ balance: null,
18
+
19
+ methods: [],
20
+ paymentDetail: [],
21
+
22
+ currentWithdrawLimit: null,
23
+ targetWithdrawLimit: null,
24
+
25
+ maxWithdrawAmount: null,
26
+ availableWithdrawAmount: null,
27
+ enableWithdraw: false,
28
+ enableWithdrawAmount: 0,
29
+ withdrawRules: [],
30
+ withdrawRule: {},
31
+ attachmentType: null, // null | 'withdraw' | 'pool'
32
+ networks: [],
33
+ selectedNetwork: null,
34
+ address: '',
35
+ amount: null,
36
+ charge: null,
37
+ realAmount: null,
38
+
39
+ // otp
40
+ requestId: null,
41
+ status: null,
42
+ target: null,
43
+ ttl: null,
44
+ },
45
+ states: {
46
+ loading: {
47
+ invoke: {
48
+ src: 'fetchInitData',
49
+ onDone: {
50
+ target: 'pending',
51
+ actions: ['setInitData', 'preset'],
52
+ },
53
+ onError: {
54
+ target: 'fail',
55
+ },
56
+ },
57
+ },
58
+ pending: {
59
+ on: {
60
+ SET_MODE: {
61
+ target: 'fetching',
62
+ actions: 'setMode',
63
+ },
64
+ },
65
+ },
66
+ fetching: {
67
+ invoke: {
68
+ src: 'fetchWithdrawRules',
69
+ onDone: {
70
+ target: 'mode',
71
+ actions: 'updateWithdrawCondition',
72
+ },
73
+ onError: {
74
+ target: '#withdraw_crypto2.fail',
75
+ },
76
+ },
77
+ },
78
+ mode: {
79
+ always: [{ target: 'activity', cond: 'isActivity' }, { target: 'cash' }],
80
+ },
81
+ activity: {
82
+ initial: 'checking',
83
+ states: {
84
+ checking: {
85
+ always: [{ target: 'convertible', cond: 'isConvertible' }, { target: 'notConvertible' }],
86
+ },
87
+ notConvertible: {
88
+ on: {
89
+ GIVE_UP: {
90
+ target: 'fetchWithdrawRule',
91
+ },
92
+ },
93
+ },
94
+ fetchWithdrawRule: {
95
+ invoke: {
96
+ src: 'fetchWithdrawRulePreview',
97
+ onDone: {
98
+ target: 'giveUp',
99
+ actions: 'setWithdrawRulePreview',
100
+ },
101
+ onError: {
102
+ target: 'notConvertible',
103
+ },
104
+ },
105
+ },
106
+ giveUp: {
107
+ on: {
108
+ CONFIRM: {
109
+ target: 'givingUp',
110
+ },
111
+ BACK: {
112
+ target: 'notConvertible',
113
+ },
114
+ },
115
+ },
116
+ givingUp: {
117
+ invoke: {
118
+ src: 'giveUp',
119
+ onDone: {
120
+ target: 'gaveUp',
121
+ },
122
+ onError: {
123
+ target: '#withdraw_crypto2.fail',
124
+ },
125
+ },
126
+ },
127
+ gaveUp: {},
128
+ convertible: {
129
+ on: {
130
+ SUBMIT: {
131
+ target: 'converting',
132
+ actions: 'setAttachmentType',
133
+ },
134
+ },
135
+ },
136
+ converting: {
137
+ invoke: {
138
+ src: 'convertFreeCredit',
139
+ onDone: [
140
+ {
141
+ target: '#withdraw_crypto2.otp',
142
+ actions: 'setOtp',
143
+ cond: 'isOtpRequired',
144
+ },
145
+ { target: 'converted' },
146
+ ],
147
+ onError: {
148
+ target: 'convertible',
149
+ },
150
+ },
151
+ },
152
+ converted: {
153
+ always: [{ target: '#withdraw_crypto2.cash.withdrawable', cond: 'hasAttachmentType' }],
154
+ },
155
+ },
156
+ },
157
+ cash: {
158
+ initial: 'checking',
159
+ states: {
160
+ checking: {
161
+ always: [
162
+ { target: 'inProcessing', cond: 'haveProcessing' },
163
+ { target: 'notWithdrawable', cond: 'isNotWithdrawable' },
164
+ { target: 'withdrawable' },
165
+ ],
166
+ },
167
+ notWithdrawable: {},
168
+ inProcessing: {},
169
+ withdrawable: {
170
+ on: {
171
+ SET_NETWORK: {
172
+ actions: ['resetCharge', 'setNetwork'],
173
+ },
174
+ SET_ADDRESS: {
175
+ actions: 'setAddress',
176
+ },
177
+ SET_AMOUNT: {
178
+ actions: ['resetCharge', 'setAmount'],
179
+ },
180
+ CALCULATE: {
181
+ target: 'calculating',
182
+ cond: 'isCalculable',
183
+ },
184
+ PREVIEW: {
185
+ target: 'submittable',
186
+ cond: 'isSubmittable',
187
+ },
188
+ SET_ATTACHMENT_TYPE: {
189
+ actions: 'setAttachmentType',
190
+ },
191
+ POOL: {
192
+ target: 'pooling',
193
+ cond: (context, event) => {
194
+ const { amount, attachmentType } = context
195
+ return attachmentType === 'pool' && amount > 0
196
+ },
197
+ },
198
+ },
199
+ },
200
+ calculating: {
201
+ entry: 'resetCharge',
202
+ invoke: {
203
+ src: 'fetchCalculation',
204
+ onDone: {
205
+ target: 'withdrawable',
206
+ actions: 'setCalculatedResult',
207
+ },
208
+ onError: {
209
+ target: 'withdrawable',
210
+ },
211
+ },
212
+ },
213
+ submittable: {
214
+ on: {
215
+ SUBMIT: [
216
+ {
217
+ target: 'pooling',
218
+ cond: (context, event) => {
219
+ const { amount, attachmentType } = context
220
+ return attachmentType === 'pool' && amount > 0
221
+ },
222
+ },
223
+ {
224
+ target: 'submitting',
225
+ },
226
+ ],
227
+ BACK: {
228
+ target: 'withdrawable',
229
+ },
230
+ },
231
+ },
232
+ submitting: {
233
+ invoke: {
234
+ src: 'submitWithdraw',
235
+ onDone: [
236
+ {
237
+ target: '#withdraw_crypto2.otp',
238
+ actions: 'setOtp',
239
+ cond: 'isOtpRequired',
240
+ },
241
+ {
242
+ target: 'submitted',
243
+ },
244
+ ],
245
+ onError: {
246
+ target: 'withdrawable',
247
+ },
248
+ },
249
+ },
250
+ submitted: {},
251
+ pooling: {
252
+ invoke: {
253
+ src: 'pool',
254
+ onDone: { target: 'pooled' },
255
+ onError: {
256
+ target: 'withdrawable',
257
+ },
258
+ },
259
+ },
260
+ pooled: {},
261
+ },
262
+ },
263
+ otp: {
264
+ type: 'parallel',
265
+ states: {
266
+ countdown: {
267
+ after: {
268
+ 1000: {
269
+ target: 'countdown',
270
+ actions: 'decreaseTtl',
271
+ cond: (context) => context.ttl > 0,
272
+ },
273
+ },
274
+ },
275
+ verification: {
276
+ initial: 'idle',
277
+ states: {
278
+ idle: {
279
+ on: {
280
+ ACKNOWLEDGE: {
281
+ target: 'acknowledging',
282
+ },
283
+ RESET_OTP: {
284
+ target: 'reset',
285
+ },
286
+ BACK: [
287
+ {
288
+ target: '#withdraw_crypto2.activity.convertible',
289
+ cond: 'isFree',
290
+ },
291
+ {
292
+ target: '#withdraw_crypto2.cash.submittable',
293
+ },
294
+ ],
295
+ },
296
+ },
297
+ acknowledging: {
298
+ invoke: {
299
+ src: 'acknowledge',
300
+ onDone: [
301
+ {
302
+ target: '#withdraw_crypto2.activity.converted',
303
+ cond: 'isFree',
304
+ },
305
+ {
306
+ target: '#withdraw_crypto2.cash.submitted',
307
+ },
308
+ ],
309
+ onError: {
310
+ target: 'idle',
311
+ },
312
+ },
313
+ },
314
+ reset: {
315
+ invoke: {
316
+ src: 'resetOtp',
317
+ onDone: {
318
+ target: 'idle',
319
+ actions: 'setVerificationData',
320
+ },
321
+ onError: { target: 'idle' },
322
+ },
323
+ },
324
+ },
325
+ },
326
+ },
327
+ },
328
+ fail: {},
329
+ },
330
+ on: {
331
+ REFRESH: {
332
+ target: 'loading',
333
+ },
334
+ },
335
+ },
336
+ {
337
+ actions: {
338
+ setInitData: assign((context, event) => {
339
+ const method = event.data.paymentDetail?.[0]
340
+ return {
341
+ paymentDetail: event.data.paymentDetail,
342
+ crypto: method,
343
+ networks:
344
+ method?.networkName?.map?.((value, i) => {
345
+ return {
346
+ label: method?.networkOptional?.[i],
347
+ value,
348
+ icon: value,
349
+ }
350
+ }) || [],
351
+ }
352
+ }),
353
+ preset: assign((context, event) => {
354
+ const { siteConfig } = context
355
+ const methods = siteConfig?.paymentMethods?.withdraw || []
356
+ return {
357
+ methods,
358
+ attachmentType: siteConfig.walletMode > 0 ? 'withdraw' : null,
359
+ }
360
+ }),
361
+ setMode: assign((context, event) => {
362
+ return {
363
+ mode: event.data,
364
+ }
365
+ }),
366
+ updateWithdrawCondition: assign((context, event) => {
367
+ const { enableWithdraw, enableWithdrawAmount, currentWithdrawLimit, targetWithdrawLimit, balance } = event.data
368
+ const withdrawRules = event.data?.rules || []
369
+ const rules = withdrawRules.filter((rule) => rule.maxWithdrawAmount > 0)
370
+ const lastMatchedIndex = findLastIndex(rules, (rule) => balance >= rule.greaterEqualThen)
371
+
372
+ let maxWithdrawAmount = 0
373
+
374
+ if (lastMatchedIndex > -1) {
375
+ rules[lastMatchedIndex].match = true
376
+ maxWithdrawAmount = rules[lastMatchedIndex].maxWithdrawAmount
377
+ } else if (rules.length > 0) {
378
+ maxWithdrawAmount = rules[0].maxWithdrawAmount
379
+ } else {
380
+ maxWithdrawAmount = balance
381
+ }
382
+
383
+ return {
384
+ balance,
385
+ currentWithdrawLimit,
386
+ targetWithdrawLimit,
387
+ maxWithdrawAmount,
388
+ enableWithdrawAmount: +enableWithdrawAmount,
389
+ enableWithdraw,
390
+ withdrawRules,
391
+ }
392
+ }),
393
+ setWithdrawRulePreview: assign((context, event) => {
394
+ return {
395
+ withdrawRule: event.data,
396
+ }
397
+ }),
398
+ setNetwork: assign((context, event) => {
399
+ return {
400
+ selectedNetwork: event.data,
401
+ }
402
+ }),
403
+ setAddress: assign((context, event) => {
404
+ return {
405
+ address: event.data,
406
+ }
407
+ }),
408
+ setAmount: assign((context, event) => {
409
+ return {
410
+ amount: event.data,
411
+ }
412
+ }),
413
+ setCalculatedResult: assign((context, event) => {
414
+ return {
415
+ charge: event.data.charge,
416
+ }
417
+ }),
418
+ resetCharge: assign((context, event) => {
419
+ return {
420
+ charge: null,
421
+ }
422
+ }),
423
+ setOtp: assign((context, event) => {
424
+ const { requestId, status, target, ttl } = event.data
425
+ return {
426
+ requestId,
427
+ status,
428
+ target,
429
+ ttl,
430
+ }
431
+ }),
432
+ decreaseTtl: assign((context, evnet) => {
433
+ const second = context.ttl
434
+ return {
435
+ ttl: Math.max(second - 1, 0),
436
+ }
437
+ }),
438
+ setVerificationData: assign((context, event) => {
439
+ const { requestId, ttl, target } = event.data
440
+ return {
441
+ requestId,
442
+ ttl,
443
+ target,
444
+ }
445
+ }),
446
+ setAttachmentType: assign((context, event) => {
447
+ return {
448
+ attachmentType: event.data,
449
+ }
450
+ }),
451
+ },
452
+ guards: {
453
+ isActivity: (context, event) => {
454
+ return context.mode === 'ACTIVITY'
455
+ },
456
+ hasAttachmentType: (context, event) => {
457
+ return ['withdraw', 'pool'].includes(context.attachmentType)
458
+ },
459
+ haveProcessing: (context, event) => {
460
+ return (context.paymentDetail?.[0]?.processing || []).length > 0
461
+ },
462
+ isSubmittable: (context, event) => {
463
+ const { selectedNetwork, address, amount, charge } = context
464
+ return selectedNetwork && address && amount && charge
465
+ },
466
+ isConvertible: (context, event) => {
467
+ const { enableWithdraw } = context
468
+ return enableWithdraw
469
+ },
470
+ isNotWithdrawable: (context, event) => {
471
+ const { enableWithdraw } = context
472
+ return !enableWithdraw
473
+ },
474
+ isCalculable: (context, event) => {
475
+ const { selectedNetwork, amount } = context
476
+ return selectedNetwork && amount
477
+ },
478
+ isOtpRequired: (context, event) => {
479
+ return event.data?.status === 'otp-verifying'
480
+ },
481
+ },
482
+ services: {
483
+ fetchInitData: async (context, event) => {
484
+ const paymentDetail = await request.send(payment.getPaymentDetail({ transferType: 'WITHDRAW' }))
485
+ return { paymentDetail }
486
+ },
487
+ fetchWithdrawRules: async (context, event) => {
488
+ const { mode } = context
489
+ return await request.send(payment.getDoubleWalletWithdrawRule({ walletType: mode }))
490
+ },
491
+ fetchWithdrawRulePreview: async (context, event) => {
492
+ const data = await request.send(payment.getWithdrawRulePreview({ applyType: 'giveup' }))
493
+ return data
494
+ },
495
+ submitWithdraw: async (context, event) => {
496
+ const { crypto, selectedNetwork, address, amount } = context
497
+ return await request.send(
498
+ api.submitWithdrawTransactionCrypto({
499
+ method: crypto.method,
500
+ amount,
501
+ cryptoCurrency: crypto.channel,
502
+ cryptoNetwork: selectedNetwork.value,
503
+ targetAddress: address,
504
+ })
505
+ )
506
+ },
507
+ convertFreeCredit: async (context, event) => {
508
+ return await request.send(payment.convertFreeCredit({ exchangeType: 1 }))
509
+ },
510
+ fetchCalculation: async (context, event) => {
511
+ const { crypto, selectedNetwork, amount } = context
512
+ const method = crypto.method
513
+ return await request.send(
514
+ api.getWithdrawExpectedResult({
515
+ method,
516
+ amount,
517
+ cryptoNetwork: selectedNetwork.value,
518
+ })
519
+ )
520
+ },
521
+ resetOtp: async (context, event) => {
522
+ const { requestId, target } = context
523
+ return await request.send(user.otpReset({ requestId, target }))
524
+ },
525
+ acknowledge: async (context, event) => {
526
+ const { requestId, target } = context
527
+ const code = event.data
528
+ return await request.send(user.otpAcknowledge({ requestId, target, code }))
529
+ },
530
+ pool: async (context, event) => {
531
+ const { amount } = context
532
+ return await request.send(payment.restore({ amount }))
533
+ },
534
+ giveUp: async (context, event) => {
535
+ return await request.send(payment.giveUp())
536
+ },
537
+ },
538
+ }
539
+ )
540
+ }
@@ -12,7 +12,6 @@ export default function (request) {
12
12
  context: {
13
13
  mode: null,
14
14
  siteConfig: null,
15
- userInfo: null,
16
15
  balance: null,
17
16
  charge: null,
18
17
  realAmount: null,
@@ -32,7 +31,6 @@ export default function (request) {
32
31
  amount: null,
33
32
  bank: null,
34
33
  branch: null,
35
- accountNumber: null,
36
34
  holderName: null,
37
35
 
38
36
  // otp
@@ -190,7 +188,6 @@ export default function (request) {
190
188
  },
191
189
  SET_ATTACHMENT_TYPE: {
192
190
  actions: 'setAttachmentType',
193
- cond: 'isNewWalletMode',
194
191
  },
195
192
  SUBMIT: [
196
193
  {
@@ -329,19 +326,13 @@ export default function (request) {
329
326
  {
330
327
  actions: {
331
328
  setInitData: assign((context, event) => {
329
+ const { paymentDetail, bankInfo, bonus, bankList } = event.data
332
330
  return {
333
- paymentDetail: event.data.paymentDetail,
334
- bankInfo: event.data.bankInfo,
335
- bank: event.data.bankInfo[0],
336
- bonus: event.data.bonus,
337
- bankList: event.data.bankList,
338
- }
339
- }),
340
- setPaymentData: assign((context, event) => {
341
- return {
342
- bankInfo: event.data.bankInfo,
343
- bonus: event.data.bonus,
344
- paymentDetail: event.data.paymentDetail,
331
+ paymentDetail,
332
+ bankInfo,
333
+ bank: bankInfo[0],
334
+ bonus,
335
+ bankList,
345
336
  }
346
337
  }),
347
338
  preset: assign((context, event) => {
@@ -349,13 +340,12 @@ export default function (request) {
349
340
  const methods = siteConfig?.paymentMethods?.withdraw || []
350
341
  return {
351
342
  methods,
352
- siteConfig,
353
343
  attachmentType: siteConfig.walletMode > 0 ? 'withdraw' : null,
354
344
  }
355
345
  }),
356
- setWithdrawRulePreview: assign((context, event) => {
346
+ setMode: assign((context, event) => {
357
347
  return {
358
- withdrawRule: event.data,
348
+ mode: event.data,
359
349
  }
360
350
  }),
361
351
  updateWithdrawCondition: assign((context, event) => {
@@ -385,9 +375,17 @@ export default function (request) {
385
375
  withdrawRules,
386
376
  }
387
377
  }),
388
- setMode: assign((context, event) => {
378
+ setWithdrawRulePreview: assign((context, event) => {
389
379
  return {
390
- mode: event.data,
380
+ withdrawRule: event.data,
381
+ }
382
+ }),
383
+ setPaymentData: assign((context, event) => {
384
+ const { bankInfo, bonus, paymentDetail } = event.data
385
+ return {
386
+ bankInfo,
387
+ bonus,
388
+ paymentDetail,
391
389
  }
392
390
  }),
393
391
  setOtp: assign((context, event) => {
@@ -448,7 +446,6 @@ export default function (request) {
448
446
  isOtpRequired: (context, event) => {
449
447
  return event.data?.status === 'otp-verifying'
450
448
  },
451
- isNewWalletMode: (context, event) => context.siteConfig.walletMode > 0,
452
449
  },
453
450
  services: {
454
451
  fetchInitData: async (context, event) => {
@@ -468,19 +465,14 @@ export default function (request) {
468
465
  const { bonus, bankInfo } = await request.send(payment.getPaymentInfo())
469
466
  return { bonus, bankInfo, paymentDetail }
470
467
  },
468
+ fetchWithdrawRules: async (context, event) => {
469
+ const { mode } = context
470
+ return await request.send(payment.getDoubleWalletWithdrawRule({ walletType: mode }))
471
+ },
471
472
  fetchWithdrawRulePreview: async (context, event) => {
472
473
  const data = await request.send(payment.getWithdrawRulePreview({ applyType: 'giveup' }))
473
474
  return data
474
475
  },
475
- fetchWithdrawRules: async (context, event) => {
476
- const { siteConfig = {}, mode } = context
477
- const { walletMode = null } = siteConfig
478
- if (walletMode === '4') {
479
- return await request.send(payment.getDoubleWalletWithdrawRule({ walletType: mode }))
480
- } else {
481
- return await request.send(payment.getCurrentWithdrawRule())
482
- }
483
- },
484
476
  submitWithdraw: async (context, event) => {
485
477
  const { bank, amount } = context
486
478
  const { method } = context.paymentDetail[0]