@jetthai/cuora 1.1.21 → 1.1.23

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,6 +2,10 @@
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.23](https://github.com/jetthai/cuora-module/compare/v1.1.22...v1.1.23) (2023-01-03)
6
+
7
+ ### [1.1.22](https://github.com/jetthai/cuora-module/compare/v1.1.21...v1.1.22) (2023-01-03)
8
+
5
9
  ### [1.1.21](https://github.com/jetthai/cuora-module/compare/v1.1.20...v1.1.21) (2022-12-30)
6
10
 
7
11
  ### [1.1.20](https://github.com/jetthai/cuora-module/compare/v1.1.19...v1.1.20) (2022-12-30)
package/dist/bundle.mjs CHANGED
@@ -11254,6 +11254,11 @@ function game_v2 (request) {
11254
11254
  parentCategoryId: null,
11255
11255
  totalPage: 1,
11256
11256
  },
11257
+ addition: {
11258
+ data: [],
11259
+ timestamp: null,
11260
+ totalPage: 1,
11261
+ },
11257
11262
  // play params
11258
11263
  game: {
11259
11264
  providerId: null,
@@ -11438,6 +11443,11 @@ function game_v2 (request) {
11438
11443
  parentCategoryId: null,
11439
11444
  totalPage: 1,
11440
11445
  },
11446
+ addition: {
11447
+ data: [],
11448
+ timestamp: null,
11449
+ totalPage: 1,
11450
+ },
11441
11451
  }
11442
11452
  }),
11443
11453
  appendContent: assign((context, event) => {
@@ -11445,23 +11455,31 @@ function game_v2 (request) {
11445
11455
  if (room.categoryId === GAME_SEARCH) {
11446
11456
  return
11447
11457
  } else {
11448
- const { data, ...rest } = event.data;
11458
+ const [content, addition] = event.data;
11449
11459
  return {
11450
11460
  content: {
11451
11461
  ...context.content,
11452
- ...rest,
11453
- data: context.content.data.concat(data),
11462
+ ...content,
11463
+ data: context.content.data.concat(content.data),
11464
+ },
11465
+ addition: {
11466
+ ...context.addition,
11467
+ ...addition,
11468
+ data: context.addition.data.concat(addition.data),
11454
11469
  },
11455
11470
  }
11456
11471
  }
11457
11472
  }),
11458
11473
  swapContent: assign((context, event) => {
11459
- const item = event.data;
11460
- if (item?.data?.length) {
11461
- return {
11462
- content: event.data,
11463
- }
11474
+ const [content, addition] = event.data;
11475
+ let result = {};
11476
+ if (content?.data?.length) {
11477
+ result.content = content;
11478
+ }
11479
+ if (addition?.data?.length) {
11480
+ result.addition = addition;
11464
11481
  }
11482
+ return result
11465
11483
  }),
11466
11484
  increaseIndex: assign((context, event) => {
11467
11485
  return {
@@ -11498,7 +11516,8 @@ function game_v2 (request) {
11498
11516
  if (room.categoryId === GAME_SEARCH) {
11499
11517
  return
11500
11518
  } else {
11501
- return await request.send(game$1.getListCategory({ categoryId: room.categoryId, index }))
11519
+ const param = { categoryId: room.categoryId, index };
11520
+ return await Promise.all([request.send(game$1.getListCategory(param)), request.send(game$1.getListAddition(param))])
11502
11521
  }
11503
11522
  },
11504
11523
  updatePageContent: async (context, event) => {
@@ -11506,13 +11525,22 @@ function game_v2 (request) {
11506
11525
  if (room.categoryId === GAME_SEARCH) {
11507
11526
  return
11508
11527
  } else {
11509
- return await request.send(
11510
- game$1.getListCategoryByRange({
11511
- categoryId: room.categoryId,
11512
- end: index,
11513
- timestamp: content.timestamp,
11514
- })
11515
- )
11528
+ return await Promise.all([
11529
+ request.send(
11530
+ game$1.getListCategoryByRange({
11531
+ categoryId: room.categoryId,
11532
+ end: index,
11533
+ timestamp: content.timestamp,
11534
+ })
11535
+ ),
11536
+ request.send(
11537
+ game$1.getListAdditionByRange({
11538
+ categoryId: room.categoryId,
11539
+ end: index,
11540
+ timestamp: content.timestamp,
11541
+ })
11542
+ ),
11543
+ ])
11516
11544
  }
11517
11545
  },
11518
11546
  connectGame: async (context, event) => {
@@ -14775,7 +14803,7 @@ function withdraw_vn (request) {
14775
14803
  bankList: [],
14776
14804
  withdrawLimit: null,
14777
14805
  targetWithdrawLimit: null,
14778
- attachmentType: null, // 'withdraw' or 'pool'
14806
+ attachmentType: null, // null | 'withdraw' | 'pool'
14779
14807
  maximumWithdrawAmount: 0,
14780
14808
  enableWithdrawAmount: 0,
14781
14809
 
@@ -15251,6 +15279,8 @@ function withdraw_crypto (request) {
15251
15279
  maxWithdrawAmount: null,
15252
15280
  availableWithdrawAmount: null,
15253
15281
 
15282
+ attachmentType: null, // null | 'withdraw' | 'pool'
15283
+
15254
15284
  networks: [],
15255
15285
  selectedNetwork: null,
15256
15286
  address: '',
@@ -15271,7 +15301,7 @@ function withdraw_crypto (request) {
15271
15301
  src: 'fetchInitData',
15272
15302
  onDone: {
15273
15303
  target: 'mode',
15274
- actions: ['setInitData', 'preset'],
15304
+ actions: ['setInitData', 'preset', 'updateWithdrawCondition'],
15275
15305
  },
15276
15306
  onError: {
15277
15307
  target: 'fail',
@@ -15282,34 +15312,53 @@ function withdraw_crypto (request) {
15282
15312
  always: [{ target: 'free', cond: 'isFree' }, { target: 'cash' }],
15283
15313
  },
15284
15314
  free: {
15285
- initial: 'loading',
15315
+ initial: 'checking',
15286
15316
  states: {
15287
- loading: {
15317
+ // loading: {
15318
+ // invoke: {
15319
+ // src: 'fetchWithdrawRules',
15320
+ // onDone: {
15321
+ // target: 'checking',
15322
+ // actions: 'updateWithdrawCondition',
15323
+ // },
15324
+ // onError: {
15325
+ // target: 'notConvertible',
15326
+ // },
15327
+ // },
15328
+ // },
15329
+ checking: {
15330
+ always: [{ target: 'convertible', cond: 'isConvertible' }, { target: 'notConvertible' }],
15331
+ },
15332
+ notConvertible: {
15333
+ on: {
15334
+ GIVE_UP: {
15335
+ target: 'givingUp',
15336
+ },
15337
+ },
15338
+ },
15339
+ givingUp: {
15288
15340
  invoke: {
15289
- src: 'fetchWithdrawRules',
15341
+ src: 'giveUp',
15290
15342
  onDone: {
15291
- target: 'checking',
15292
- actions: 'updateWithdrawCondition',
15343
+ target: 'gaveUp',
15293
15344
  },
15294
15345
  onError: {
15295
- target: 'notConvertible',
15346
+ target: 'convertible',
15296
15347
  },
15297
15348
  },
15298
15349
  },
15299
- checking: {
15300
- always: [{ target: 'convertible', cond: 'isConvertible' }, { target: 'notConvertible' }],
15301
- },
15302
- notConvertible: {},
15350
+ gaveUp: {},
15303
15351
  convertible: {
15304
15352
  on: {
15305
15353
  SUBMIT: {
15306
15354
  target: 'converting',
15355
+ actions: 'setAttachmentType',
15307
15356
  },
15308
15357
  },
15309
15358
  },
15310
15359
  converting: {
15311
15360
  invoke: {
15312
- src: 'submitWithdrawFree',
15361
+ src: 'convertFreeCredit',
15313
15362
  onDone: [
15314
15363
  {
15315
15364
  target: '#withdraw_crypto.otp',
@@ -15325,7 +15374,9 @@ function withdraw_crypto (request) {
15325
15374
  },
15326
15375
  },
15327
15376
  },
15328
- converted: {},
15377
+ converted: {
15378
+ always: [{ target: '#withdraw_crypto.cash.withdrawable', cond: 'hasAttachmentType' }],
15379
+ },
15329
15380
  },
15330
15381
  },
15331
15382
  cash: {
@@ -15359,6 +15410,17 @@ function withdraw_crypto (request) {
15359
15410
  target: 'submittable',
15360
15411
  cond: 'isSubmittable',
15361
15412
  },
15413
+ SET_ATTACHMENT_TYPE: {
15414
+ actions: 'setAttachmentType',
15415
+ cond: 'isNewWalletMode',
15416
+ },
15417
+ POOL: {
15418
+ target: 'pooling',
15419
+ cond: (context, event) => {
15420
+ const { amount, attachmentType } = context;
15421
+ return attachmentType === 'pool' && amount > 0
15422
+ },
15423
+ },
15362
15424
  },
15363
15425
  },
15364
15426
  calculating: {
@@ -15376,9 +15438,18 @@ function withdraw_crypto (request) {
15376
15438
  },
15377
15439
  submittable: {
15378
15440
  on: {
15379
- SUBMIT: {
15380
- target: 'submitting',
15381
- },
15441
+ SUBMIT: [
15442
+ {
15443
+ target: 'pooling',
15444
+ cond: (context, event) => {
15445
+ const { amount, attachmentType } = context;
15446
+ return attachmentType === 'pool' && amount > 0
15447
+ },
15448
+ },
15449
+ {
15450
+ target: 'submitting',
15451
+ },
15452
+ ],
15382
15453
  BACK: {
15383
15454
  target: 'withdrawable',
15384
15455
  },
@@ -15403,6 +15474,16 @@ function withdraw_crypto (request) {
15403
15474
  },
15404
15475
  },
15405
15476
  submitted: {},
15477
+ pooling: {
15478
+ invoke: {
15479
+ src: 'pool',
15480
+ onDone: { target: 'pooled' },
15481
+ onError: {
15482
+ target: 'withdrawable',
15483
+ },
15484
+ },
15485
+ },
15486
+ pooled: {},
15406
15487
  },
15407
15488
  },
15408
15489
  otp: {
@@ -15512,34 +15593,46 @@ function withdraw_crypto (request) {
15512
15593
  balance,
15513
15594
  siteConfig,
15514
15595
  userInfo,
15596
+ attachmentType: siteConfig.walletMode > 0 ? 'withdraw' : null,
15515
15597
  }
15516
15598
  }),
15517
15599
  updateWithdrawCondition: assign((context, event) => {
15518
- const rules = event.data.rules.filter((rule) => rule.maxWithdrawAmount > 0);
15519
-
15520
- const { balance, withdrawLimit } = context;
15521
- const lastMatchedIndex = findLastIndex_1(rules, (rule) => balance >= rule.greaterEqualThen);
15522
-
15523
- let maxWithdrawAmount = 0,
15524
- availableWithdrawAmount = 0;
15525
-
15526
- if (lastMatchedIndex > -1) {
15527
- rules[lastMatchedIndex].match = true;
15528
- maxWithdrawAmount = rules[lastMatchedIndex].maxWithdrawAmount;
15529
-
15530
- if (withdrawLimit === 0) {
15531
- availableWithdrawAmount = Math.min(balance, maxWithdrawAmount);
15532
- }
15533
- } else if (rules.length > 0) {
15534
- maxWithdrawAmount = rules[0].maxWithdrawAmount;
15535
- } else {
15536
- maxWithdrawAmount = balance;
15537
- }
15600
+ const { differAmountLimit, enableWithdraw, enableWithdrawAmount, maxWithdrawStatus, maximumWithdrawAmount, minimumWithdrawAmount } =
15601
+ event.data?.withdrawRule;
15538
15602
 
15539
15603
  return {
15540
- maxWithdrawAmount,
15541
- availableWithdrawAmount,
15604
+ // maxWithdrawAmount: maximumWithdrawAmount,
15605
+ // availableWithdrawAmount: enableWithdrawAmount,
15606
+ maximumWithdrawAmount: +maximumWithdrawAmount,
15607
+ enableWithdrawAmount: +enableWithdrawAmount,
15608
+ amount: +enableWithdrawAmount,
15542
15609
  }
15610
+
15611
+ // const rules = event.data.rules.filter((rule) => rule.maxWithdrawAmount > 0)
15612
+ //
15613
+ // const { balance, withdrawLimit } = context
15614
+ // const lastMatchedIndex = findLastIndex(rules, (rule) => balance >= rule.greaterEqualThen)
15615
+ //
15616
+ // let maxWithdrawAmount = 0,
15617
+ // availableWithdrawAmount = 0
15618
+ //
15619
+ // if (lastMatchedIndex > -1) {
15620
+ // rules[lastMatchedIndex].match = true
15621
+ // maxWithdrawAmount = rules[lastMatchedIndex].maxWithdrawAmount
15622
+ //
15623
+ // if (withdrawLimit === 0) {
15624
+ // availableWithdrawAmount = Math.min(balance, maxWithdrawAmount)
15625
+ // }
15626
+ // } else if (rules.length > 0) {
15627
+ // maxWithdrawAmount = rules[0].maxWithdrawAmount
15628
+ // } else {
15629
+ // maxWithdrawAmount = balance
15630
+ // }
15631
+ //
15632
+ // return {
15633
+ // maxWithdrawAmount,
15634
+ // availableWithdrawAmount,
15635
+ // }
15543
15636
  }),
15544
15637
  setNetwork: assign((context, event) => {
15545
15638
  return {
@@ -15595,11 +15688,19 @@ function withdraw_crypto (request) {
15595
15688
  target,
15596
15689
  }
15597
15690
  }),
15691
+ setAttachmentType: assign((context, event) => {
15692
+ return {
15693
+ attachmentType: event.data,
15694
+ }
15695
+ }),
15598
15696
  },
15599
15697
  guards: {
15600
15698
  isFree: (context, event) => {
15601
15699
  return context.userInfo?.withdraw_rule !== 'DEFAULT'
15602
15700
  },
15701
+ hasAttachmentType: (context, event) => {
15702
+ return ['withdraw', 'pool'].includes(context.attachmentType)
15703
+ },
15603
15704
  haveProcessing: (context, event) => {
15604
15705
  return (context.paymentDetail?.[0]?.processing || []).length > 0
15605
15706
  },
@@ -15628,16 +15729,18 @@ function withdraw_crypto (request) {
15628
15729
  isOtpRequired: (context, event) => {
15629
15730
  return event.data?.status === 'otp-verifying'
15630
15731
  },
15732
+ isNewWalletMode: (context, event) => context.siteConfig.walletMode > 0,
15631
15733
  },
15632
15734
  services: {
15633
15735
  fetchInitData: async (context, event) => {
15634
- const [{ config }, userInfo, paymentDetail = []] = await Promise.all([
15736
+ const [{ config }, userInfo, paymentDetail = [], withdrawRule] = await Promise.all([
15635
15737
  request.send(common$1.getConfig({ appSecret })),
15636
15738
  request.send(user.getUserInfo()),
15637
15739
  request.send(payment.getPaymentDetail({ transferType: 'WITHDRAW' })),
15740
+ request.send(payment.getCurrentWithdrawRule()),
15638
15741
  ]);
15639
15742
  const siteConfig = JSON.parse(window.atob(config));
15640
- return { siteConfig, userInfo, paymentDetail }
15743
+ return { siteConfig, userInfo, paymentDetail, withdrawRule }
15641
15744
  },
15642
15745
  fetchPaymentData: async (context, event) => {
15643
15746
  const paymentDetail = await request.send(payment.getPaymentDetail({ transferType: 'WITHDRAW' }));
@@ -15658,7 +15761,7 @@ function withdraw_crypto (request) {
15658
15761
  })
15659
15762
  )
15660
15763
  },
15661
- submitWithdrawFree: async (context, event) => {
15764
+ convertFreeCredit: async (context, event) => {
15662
15765
  return await request.send(payment.convertFreeCredit({ exchangeType: 1 }))
15663
15766
  },
15664
15767
  fetchCalculation: async (context, event) => {
@@ -15681,6 +15784,13 @@ function withdraw_crypto (request) {
15681
15784
  const code = event.data;
15682
15785
  return await request.send(user.otpAcknowledge({ requestId, target, code }))
15683
15786
  },
15787
+ pool: async (context, event) => {
15788
+ const { amount } = context;
15789
+ return await request.send(payment.restore({ amount }))
15790
+ },
15791
+ giveUp: async (context, event) => {
15792
+ return await request.send(payment.giveUp())
15793
+ },
15684
15794
  },
15685
15795
  }
15686
15796
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.21",
3
+ "version": "1.1.23",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -17,6 +17,11 @@ export default function (request) {
17
17
  parentCategoryId: null,
18
18
  totalPage: 1,
19
19
  },
20
+ addition: {
21
+ data: [],
22
+ timestamp: null,
23
+ totalPage: 1,
24
+ },
20
25
  // play params
21
26
  game: {
22
27
  providerId: null,
@@ -201,6 +206,11 @@ export default function (request) {
201
206
  parentCategoryId: null,
202
207
  totalPage: 1,
203
208
  },
209
+ addition: {
210
+ data: [],
211
+ timestamp: null,
212
+ totalPage: 1,
213
+ },
204
214
  }
205
215
  }),
206
216
  appendContent: assign((context, event) => {
@@ -208,23 +218,31 @@ export default function (request) {
208
218
  if (room.categoryId === GAME_SEARCH) {
209
219
  return
210
220
  } else {
211
- const { data, ...rest } = event.data
221
+ const [content, addition] = event.data
212
222
  return {
213
223
  content: {
214
224
  ...context.content,
215
- ...rest,
216
- data: context.content.data.concat(data),
225
+ ...content,
226
+ data: context.content.data.concat(content.data),
227
+ },
228
+ addition: {
229
+ ...context.addition,
230
+ ...addition,
231
+ data: context.addition.data.concat(addition.data),
217
232
  },
218
233
  }
219
234
  }
220
235
  }),
221
236
  swapContent: assign((context, event) => {
222
- const item = event.data
223
- if (item?.data?.length) {
224
- return {
225
- content: event.data,
226
- }
237
+ const [content, addition] = event.data
238
+ let result = {}
239
+ if (content?.data?.length) {
240
+ result.content = content
241
+ }
242
+ if (addition?.data?.length) {
243
+ result.addition = addition
227
244
  }
245
+ return result
228
246
  }),
229
247
  increaseIndex: assign((context, event) => {
230
248
  return {
@@ -261,7 +279,8 @@ export default function (request) {
261
279
  if (room.categoryId === GAME_SEARCH) {
262
280
  return
263
281
  } else {
264
- return await request.send(api.getListCategory({ categoryId: room.categoryId, index }))
282
+ const param = { categoryId: room.categoryId, index }
283
+ return await Promise.all([request.send(api.getListCategory(param)), request.send(api.getListAddition(param))])
265
284
  }
266
285
  },
267
286
  updatePageContent: async (context, event) => {
@@ -269,13 +288,22 @@ export default function (request) {
269
288
  if (room.categoryId === GAME_SEARCH) {
270
289
  return
271
290
  } else {
272
- return await request.send(
273
- api.getListCategoryByRange({
274
- categoryId: room.categoryId,
275
- end: index,
276
- timestamp: content.timestamp,
277
- })
278
- )
291
+ return await Promise.all([
292
+ request.send(
293
+ api.getListCategoryByRange({
294
+ categoryId: room.categoryId,
295
+ end: index,
296
+ timestamp: content.timestamp,
297
+ })
298
+ ),
299
+ request.send(
300
+ api.getListAdditionByRange({
301
+ categoryId: room.categoryId,
302
+ end: index,
303
+ timestamp: content.timestamp,
304
+ })
305
+ ),
306
+ ])
279
307
  }
280
308
  },
281
309
  connectGame: async (context, event) => {
@@ -25,6 +25,8 @@ export default function (request) {
25
25
  maxWithdrawAmount: null,
26
26
  availableWithdrawAmount: null,
27
27
 
28
+ attachmentType: null, // null | 'withdraw' | 'pool'
29
+
28
30
  networks: [],
29
31
  selectedNetwork: null,
30
32
  address: '',
@@ -45,7 +47,7 @@ export default function (request) {
45
47
  src: 'fetchInitData',
46
48
  onDone: {
47
49
  target: 'mode',
48
- actions: ['setInitData', 'preset'],
50
+ actions: ['setInitData', 'preset', 'updateWithdrawCondition'],
49
51
  },
50
52
  onError: {
51
53
  target: 'fail',
@@ -56,34 +58,53 @@ export default function (request) {
56
58
  always: [{ target: 'free', cond: 'isFree' }, { target: 'cash' }],
57
59
  },
58
60
  free: {
59
- initial: 'loading',
61
+ initial: 'checking',
60
62
  states: {
61
- loading: {
63
+ // loading: {
64
+ // invoke: {
65
+ // src: 'fetchWithdrawRules',
66
+ // onDone: {
67
+ // target: 'checking',
68
+ // actions: 'updateWithdrawCondition',
69
+ // },
70
+ // onError: {
71
+ // target: 'notConvertible',
72
+ // },
73
+ // },
74
+ // },
75
+ checking: {
76
+ always: [{ target: 'convertible', cond: 'isConvertible' }, { target: 'notConvertible' }],
77
+ },
78
+ notConvertible: {
79
+ on: {
80
+ GIVE_UP: {
81
+ target: 'givingUp',
82
+ },
83
+ },
84
+ },
85
+ givingUp: {
62
86
  invoke: {
63
- src: 'fetchWithdrawRules',
87
+ src: 'giveUp',
64
88
  onDone: {
65
- target: 'checking',
66
- actions: 'updateWithdrawCondition',
89
+ target: 'gaveUp',
67
90
  },
68
91
  onError: {
69
- target: 'notConvertible',
92
+ target: 'convertible',
70
93
  },
71
94
  },
72
95
  },
73
- checking: {
74
- always: [{ target: 'convertible', cond: 'isConvertible' }, { target: 'notConvertible' }],
75
- },
76
- notConvertible: {},
96
+ gaveUp: {},
77
97
  convertible: {
78
98
  on: {
79
99
  SUBMIT: {
80
100
  target: 'converting',
101
+ actions: 'setAttachmentType',
81
102
  },
82
103
  },
83
104
  },
84
105
  converting: {
85
106
  invoke: {
86
- src: 'submitWithdrawFree',
107
+ src: 'convertFreeCredit',
87
108
  onDone: [
88
109
  {
89
110
  target: '#withdraw_crypto.otp',
@@ -99,7 +120,9 @@ export default function (request) {
99
120
  },
100
121
  },
101
122
  },
102
- converted: {},
123
+ converted: {
124
+ always: [{ target: '#withdraw_crypto.cash.withdrawable', cond: 'hasAttachmentType' }],
125
+ },
103
126
  },
104
127
  },
105
128
  cash: {
@@ -133,6 +156,17 @@ export default function (request) {
133
156
  target: 'submittable',
134
157
  cond: 'isSubmittable',
135
158
  },
159
+ SET_ATTACHMENT_TYPE: {
160
+ actions: 'setAttachmentType',
161
+ cond: 'isNewWalletMode',
162
+ },
163
+ POOL: {
164
+ target: 'pooling',
165
+ cond: (context, event) => {
166
+ const { amount, attachmentType } = context
167
+ return attachmentType === 'pool' && amount > 0
168
+ },
169
+ },
136
170
  },
137
171
  },
138
172
  calculating: {
@@ -150,9 +184,18 @@ export default function (request) {
150
184
  },
151
185
  submittable: {
152
186
  on: {
153
- SUBMIT: {
154
- target: 'submitting',
155
- },
187
+ SUBMIT: [
188
+ {
189
+ target: 'pooling',
190
+ cond: (context, event) => {
191
+ const { amount, attachmentType } = context
192
+ return attachmentType === 'pool' && amount > 0
193
+ },
194
+ },
195
+ {
196
+ target: 'submitting',
197
+ },
198
+ ],
156
199
  BACK: {
157
200
  target: 'withdrawable',
158
201
  },
@@ -177,6 +220,16 @@ export default function (request) {
177
220
  },
178
221
  },
179
222
  submitted: {},
223
+ pooling: {
224
+ invoke: {
225
+ src: 'pool',
226
+ onDone: { target: 'pooled' },
227
+ onError: {
228
+ target: 'withdrawable',
229
+ },
230
+ },
231
+ },
232
+ pooled: {},
180
233
  },
181
234
  },
182
235
  otp: {
@@ -286,34 +339,46 @@ export default function (request) {
286
339
  balance,
287
340
  siteConfig,
288
341
  userInfo,
342
+ attachmentType: siteConfig.walletMode > 0 ? 'withdraw' : null,
289
343
  }
290
344
  }),
291
345
  updateWithdrawCondition: assign((context, event) => {
292
- const rules = event.data.rules.filter((rule) => rule.maxWithdrawAmount > 0)
293
-
294
- const { balance, withdrawLimit } = context
295
- const lastMatchedIndex = findLastIndex(rules, (rule) => balance >= rule.greaterEqualThen)
296
-
297
- let maxWithdrawAmount = 0,
298
- availableWithdrawAmount = 0
299
-
300
- if (lastMatchedIndex > -1) {
301
- rules[lastMatchedIndex].match = true
302
- maxWithdrawAmount = rules[lastMatchedIndex].maxWithdrawAmount
303
-
304
- if (withdrawLimit === 0) {
305
- availableWithdrawAmount = Math.min(balance, maxWithdrawAmount)
306
- }
307
- } else if (rules.length > 0) {
308
- maxWithdrawAmount = rules[0].maxWithdrawAmount
309
- } else {
310
- maxWithdrawAmount = balance
311
- }
346
+ const { differAmountLimit, enableWithdraw, enableWithdrawAmount, maxWithdrawStatus, maximumWithdrawAmount, minimumWithdrawAmount } =
347
+ event.data?.withdrawRule
312
348
 
313
349
  return {
314
- maxWithdrawAmount,
315
- availableWithdrawAmount,
350
+ // maxWithdrawAmount: maximumWithdrawAmount,
351
+ // availableWithdrawAmount: enableWithdrawAmount,
352
+ maximumWithdrawAmount: +maximumWithdrawAmount,
353
+ enableWithdrawAmount: +enableWithdrawAmount,
354
+ amount: +enableWithdrawAmount,
316
355
  }
356
+
357
+ // const rules = event.data.rules.filter((rule) => rule.maxWithdrawAmount > 0)
358
+ //
359
+ // const { balance, withdrawLimit } = context
360
+ // const lastMatchedIndex = findLastIndex(rules, (rule) => balance >= rule.greaterEqualThen)
361
+ //
362
+ // let maxWithdrawAmount = 0,
363
+ // availableWithdrawAmount = 0
364
+ //
365
+ // if (lastMatchedIndex > -1) {
366
+ // rules[lastMatchedIndex].match = true
367
+ // maxWithdrawAmount = rules[lastMatchedIndex].maxWithdrawAmount
368
+ //
369
+ // if (withdrawLimit === 0) {
370
+ // availableWithdrawAmount = Math.min(balance, maxWithdrawAmount)
371
+ // }
372
+ // } else if (rules.length > 0) {
373
+ // maxWithdrawAmount = rules[0].maxWithdrawAmount
374
+ // } else {
375
+ // maxWithdrawAmount = balance
376
+ // }
377
+ //
378
+ // return {
379
+ // maxWithdrawAmount,
380
+ // availableWithdrawAmount,
381
+ // }
317
382
  }),
318
383
  setNetwork: assign((context, event) => {
319
384
  return {
@@ -369,11 +434,19 @@ export default function (request) {
369
434
  target,
370
435
  }
371
436
  }),
437
+ setAttachmentType: assign((context, event) => {
438
+ return {
439
+ attachmentType: event.data,
440
+ }
441
+ }),
372
442
  },
373
443
  guards: {
374
444
  isFree: (context, event) => {
375
445
  return context.userInfo?.withdraw_rule !== 'DEFAULT'
376
446
  },
447
+ hasAttachmentType: (context, event) => {
448
+ return ['withdraw', 'pool'].includes(context.attachmentType)
449
+ },
377
450
  haveProcessing: (context, event) => {
378
451
  return (context.paymentDetail?.[0]?.processing || []).length > 0
379
452
  },
@@ -402,16 +475,18 @@ export default function (request) {
402
475
  isOtpRequired: (context, event) => {
403
476
  return event.data?.status === 'otp-verifying'
404
477
  },
478
+ isNewWalletMode: (context, event) => context.siteConfig.walletMode > 0,
405
479
  },
406
480
  services: {
407
481
  fetchInitData: async (context, event) => {
408
- const [{ config }, userInfo, paymentDetail = []] = await Promise.all([
482
+ const [{ config }, userInfo, paymentDetail = [], withdrawRule] = await Promise.all([
409
483
  request.send(common.getConfig({ appSecret })),
410
484
  request.send(user.getUserInfo()),
411
485
  request.send(payment.getPaymentDetail({ transferType: 'WITHDRAW' })),
486
+ request.send(payment.getCurrentWithdrawRule()),
412
487
  ])
413
488
  const siteConfig = JSON.parse(window.atob(config))
414
- return { siteConfig, userInfo, paymentDetail }
489
+ return { siteConfig, userInfo, paymentDetail, withdrawRule }
415
490
  },
416
491
  fetchPaymentData: async (context, event) => {
417
492
  const paymentDetail = await request.send(payment.getPaymentDetail({ transferType: 'WITHDRAW' }))
@@ -432,7 +507,7 @@ export default function (request) {
432
507
  })
433
508
  )
434
509
  },
435
- submitWithdrawFree: async (context, event) => {
510
+ convertFreeCredit: async (context, event) => {
436
511
  return await request.send(payment.convertFreeCredit({ exchangeType: 1 }))
437
512
  },
438
513
  fetchCalculation: async (context, event) => {
@@ -455,6 +530,13 @@ export default function (request) {
455
530
  const code = event.data
456
531
  return await request.send(user.otpAcknowledge({ requestId, target, code }))
457
532
  },
533
+ pool: async (context, event) => {
534
+ const { amount } = context
535
+ return await request.send(payment.restore({ amount }))
536
+ },
537
+ giveUp: async (context, event) => {
538
+ return await request.send(payment.giveUp())
539
+ },
458
540
  },
459
541
  }
460
542
  )
@@ -23,7 +23,7 @@ export default function (request) {
23
23
  bankList: [],
24
24
  withdrawLimit: null,
25
25
  targetWithdrawLimit: null,
26
- attachmentType: null, // 'withdraw' or 'pool'
26
+ attachmentType: null, // null | 'withdraw' | 'pool'
27
27
  maximumWithdrawAmount: 0,
28
28
  enableWithdrawAmount: 0,
29
29