@jetthai/cuora 1.1.21 → 1.1.22
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 +2 -0
- package/dist/bundle.mjs +124 -42
- package/package.json +1 -1
- package/src/machine/withdraw_crypto.js +123 -41
- package/src/machine/withdraw_vn.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
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.22](https://github.com/jetthai/cuora-module/compare/v1.1.21...v1.1.22) (2023-01-03)
|
|
6
|
+
|
|
5
7
|
### [1.1.21](https://github.com/jetthai/cuora-module/compare/v1.1.20...v1.1.21) (2022-12-30)
|
|
6
8
|
|
|
7
9
|
### [1.1.20](https://github.com/jetthai/cuora-module/compare/v1.1.19...v1.1.20) (2022-12-30)
|
package/dist/bundle.mjs
CHANGED
|
@@ -14775,7 +14775,7 @@ function withdraw_vn (request) {
|
|
|
14775
14775
|
bankList: [],
|
|
14776
14776
|
withdrawLimit: null,
|
|
14777
14777
|
targetWithdrawLimit: null,
|
|
14778
|
-
attachmentType: null, // 'withdraw'
|
|
14778
|
+
attachmentType: null, // null | 'withdraw' | 'pool'
|
|
14779
14779
|
maximumWithdrawAmount: 0,
|
|
14780
14780
|
enableWithdrawAmount: 0,
|
|
14781
14781
|
|
|
@@ -15251,6 +15251,8 @@ function withdraw_crypto (request) {
|
|
|
15251
15251
|
maxWithdrawAmount: null,
|
|
15252
15252
|
availableWithdrawAmount: null,
|
|
15253
15253
|
|
|
15254
|
+
attachmentType: null, // null | 'withdraw' | 'pool'
|
|
15255
|
+
|
|
15254
15256
|
networks: [],
|
|
15255
15257
|
selectedNetwork: null,
|
|
15256
15258
|
address: '',
|
|
@@ -15271,7 +15273,7 @@ function withdraw_crypto (request) {
|
|
|
15271
15273
|
src: 'fetchInitData',
|
|
15272
15274
|
onDone: {
|
|
15273
15275
|
target: 'mode',
|
|
15274
|
-
actions: ['setInitData', 'preset'],
|
|
15276
|
+
actions: ['setInitData', 'preset', 'updateWithdrawCondition'],
|
|
15275
15277
|
},
|
|
15276
15278
|
onError: {
|
|
15277
15279
|
target: 'fail',
|
|
@@ -15282,34 +15284,53 @@ function withdraw_crypto (request) {
|
|
|
15282
15284
|
always: [{ target: 'free', cond: 'isFree' }, { target: 'cash' }],
|
|
15283
15285
|
},
|
|
15284
15286
|
free: {
|
|
15285
|
-
initial: '
|
|
15287
|
+
initial: 'checking',
|
|
15286
15288
|
states: {
|
|
15287
|
-
loading: {
|
|
15289
|
+
// loading: {
|
|
15290
|
+
// invoke: {
|
|
15291
|
+
// src: 'fetchWithdrawRules',
|
|
15292
|
+
// onDone: {
|
|
15293
|
+
// target: 'checking',
|
|
15294
|
+
// actions: 'updateWithdrawCondition',
|
|
15295
|
+
// },
|
|
15296
|
+
// onError: {
|
|
15297
|
+
// target: 'notConvertible',
|
|
15298
|
+
// },
|
|
15299
|
+
// },
|
|
15300
|
+
// },
|
|
15301
|
+
checking: {
|
|
15302
|
+
always: [{ target: 'convertible', cond: 'isConvertible' }, { target: 'notConvertible' }],
|
|
15303
|
+
},
|
|
15304
|
+
notConvertible: {
|
|
15305
|
+
on: {
|
|
15306
|
+
GIVE_UP: {
|
|
15307
|
+
target: 'givingUp',
|
|
15308
|
+
},
|
|
15309
|
+
},
|
|
15310
|
+
},
|
|
15311
|
+
givingUp: {
|
|
15288
15312
|
invoke: {
|
|
15289
|
-
src: '
|
|
15313
|
+
src: 'giveUp',
|
|
15290
15314
|
onDone: {
|
|
15291
|
-
target: '
|
|
15292
|
-
actions: 'updateWithdrawCondition',
|
|
15315
|
+
target: 'gaveUp',
|
|
15293
15316
|
},
|
|
15294
15317
|
onError: {
|
|
15295
|
-
target: '
|
|
15318
|
+
target: 'convertible',
|
|
15296
15319
|
},
|
|
15297
15320
|
},
|
|
15298
15321
|
},
|
|
15299
|
-
|
|
15300
|
-
always: [{ target: 'convertible', cond: 'isConvertible' }, { target: 'notConvertible' }],
|
|
15301
|
-
},
|
|
15302
|
-
notConvertible: {},
|
|
15322
|
+
gaveUp: {},
|
|
15303
15323
|
convertible: {
|
|
15304
15324
|
on: {
|
|
15305
15325
|
SUBMIT: {
|
|
15306
15326
|
target: 'converting',
|
|
15327
|
+
actions: 'setAttachmentType',
|
|
15307
15328
|
},
|
|
15308
15329
|
},
|
|
15309
15330
|
},
|
|
15310
15331
|
converting: {
|
|
15311
15332
|
invoke: {
|
|
15312
|
-
src: '
|
|
15333
|
+
src: 'convertFreeCredit',
|
|
15313
15334
|
onDone: [
|
|
15314
15335
|
{
|
|
15315
15336
|
target: '#withdraw_crypto.otp',
|
|
@@ -15325,7 +15346,9 @@ function withdraw_crypto (request) {
|
|
|
15325
15346
|
},
|
|
15326
15347
|
},
|
|
15327
15348
|
},
|
|
15328
|
-
converted: {
|
|
15349
|
+
converted: {
|
|
15350
|
+
always: [{ target: '#withdraw_crypto.cash.withdrawable', cond: 'hasAttachmentType' }],
|
|
15351
|
+
},
|
|
15329
15352
|
},
|
|
15330
15353
|
},
|
|
15331
15354
|
cash: {
|
|
@@ -15359,6 +15382,17 @@ function withdraw_crypto (request) {
|
|
|
15359
15382
|
target: 'submittable',
|
|
15360
15383
|
cond: 'isSubmittable',
|
|
15361
15384
|
},
|
|
15385
|
+
SET_ATTACHMENT_TYPE: {
|
|
15386
|
+
actions: 'setAttachmentType',
|
|
15387
|
+
cond: 'isNewWalletMode',
|
|
15388
|
+
},
|
|
15389
|
+
POOL: {
|
|
15390
|
+
target: 'pooling',
|
|
15391
|
+
cond: (context, event) => {
|
|
15392
|
+
const { amount, attachmentType } = context;
|
|
15393
|
+
return attachmentType === 'pool' && amount > 0
|
|
15394
|
+
},
|
|
15395
|
+
},
|
|
15362
15396
|
},
|
|
15363
15397
|
},
|
|
15364
15398
|
calculating: {
|
|
@@ -15376,9 +15410,18 @@ function withdraw_crypto (request) {
|
|
|
15376
15410
|
},
|
|
15377
15411
|
submittable: {
|
|
15378
15412
|
on: {
|
|
15379
|
-
SUBMIT:
|
|
15380
|
-
|
|
15381
|
-
|
|
15413
|
+
SUBMIT: [
|
|
15414
|
+
{
|
|
15415
|
+
target: 'pooling',
|
|
15416
|
+
cond: (context, event) => {
|
|
15417
|
+
const { amount, attachmentType } = context;
|
|
15418
|
+
return attachmentType === 'pool' && amount > 0
|
|
15419
|
+
},
|
|
15420
|
+
},
|
|
15421
|
+
{
|
|
15422
|
+
target: 'submitting',
|
|
15423
|
+
},
|
|
15424
|
+
],
|
|
15382
15425
|
BACK: {
|
|
15383
15426
|
target: 'withdrawable',
|
|
15384
15427
|
},
|
|
@@ -15403,6 +15446,16 @@ function withdraw_crypto (request) {
|
|
|
15403
15446
|
},
|
|
15404
15447
|
},
|
|
15405
15448
|
submitted: {},
|
|
15449
|
+
pooling: {
|
|
15450
|
+
invoke: {
|
|
15451
|
+
src: 'pool',
|
|
15452
|
+
onDone: { target: 'pooled' },
|
|
15453
|
+
onError: {
|
|
15454
|
+
target: 'withdrawable',
|
|
15455
|
+
},
|
|
15456
|
+
},
|
|
15457
|
+
},
|
|
15458
|
+
pooled: {},
|
|
15406
15459
|
},
|
|
15407
15460
|
},
|
|
15408
15461
|
otp: {
|
|
@@ -15512,34 +15565,46 @@ function withdraw_crypto (request) {
|
|
|
15512
15565
|
balance,
|
|
15513
15566
|
siteConfig,
|
|
15514
15567
|
userInfo,
|
|
15568
|
+
attachmentType: siteConfig.walletMode > 0 ? 'withdraw' : null,
|
|
15515
15569
|
}
|
|
15516
15570
|
}),
|
|
15517
15571
|
updateWithdrawCondition: assign((context, event) => {
|
|
15518
|
-
const
|
|
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
|
-
}
|
|
15572
|
+
const { differAmountLimit, enableWithdraw, enableWithdrawAmount, maxWithdrawStatus, maximumWithdrawAmount, minimumWithdrawAmount } =
|
|
15573
|
+
event.data?.withdrawRule;
|
|
15538
15574
|
|
|
15539
15575
|
return {
|
|
15540
|
-
maxWithdrawAmount,
|
|
15541
|
-
availableWithdrawAmount,
|
|
15576
|
+
// maxWithdrawAmount: maximumWithdrawAmount,
|
|
15577
|
+
// availableWithdrawAmount: enableWithdrawAmount,
|
|
15578
|
+
maximumWithdrawAmount: +maximumWithdrawAmount,
|
|
15579
|
+
enableWithdrawAmount: +enableWithdrawAmount,
|
|
15580
|
+
amount: +enableWithdrawAmount,
|
|
15542
15581
|
}
|
|
15582
|
+
|
|
15583
|
+
// const rules = event.data.rules.filter((rule) => rule.maxWithdrawAmount > 0)
|
|
15584
|
+
//
|
|
15585
|
+
// const { balance, withdrawLimit } = context
|
|
15586
|
+
// const lastMatchedIndex = findLastIndex(rules, (rule) => balance >= rule.greaterEqualThen)
|
|
15587
|
+
//
|
|
15588
|
+
// let maxWithdrawAmount = 0,
|
|
15589
|
+
// availableWithdrawAmount = 0
|
|
15590
|
+
//
|
|
15591
|
+
// if (lastMatchedIndex > -1) {
|
|
15592
|
+
// rules[lastMatchedIndex].match = true
|
|
15593
|
+
// maxWithdrawAmount = rules[lastMatchedIndex].maxWithdrawAmount
|
|
15594
|
+
//
|
|
15595
|
+
// if (withdrawLimit === 0) {
|
|
15596
|
+
// availableWithdrawAmount = Math.min(balance, maxWithdrawAmount)
|
|
15597
|
+
// }
|
|
15598
|
+
// } else if (rules.length > 0) {
|
|
15599
|
+
// maxWithdrawAmount = rules[0].maxWithdrawAmount
|
|
15600
|
+
// } else {
|
|
15601
|
+
// maxWithdrawAmount = balance
|
|
15602
|
+
// }
|
|
15603
|
+
//
|
|
15604
|
+
// return {
|
|
15605
|
+
// maxWithdrawAmount,
|
|
15606
|
+
// availableWithdrawAmount,
|
|
15607
|
+
// }
|
|
15543
15608
|
}),
|
|
15544
15609
|
setNetwork: assign((context, event) => {
|
|
15545
15610
|
return {
|
|
@@ -15595,11 +15660,19 @@ function withdraw_crypto (request) {
|
|
|
15595
15660
|
target,
|
|
15596
15661
|
}
|
|
15597
15662
|
}),
|
|
15663
|
+
setAttachmentType: assign((context, event) => {
|
|
15664
|
+
return {
|
|
15665
|
+
attachmentType: event.data,
|
|
15666
|
+
}
|
|
15667
|
+
}),
|
|
15598
15668
|
},
|
|
15599
15669
|
guards: {
|
|
15600
15670
|
isFree: (context, event) => {
|
|
15601
15671
|
return context.userInfo?.withdraw_rule !== 'DEFAULT'
|
|
15602
15672
|
},
|
|
15673
|
+
hasAttachmentType: (context, event) => {
|
|
15674
|
+
return ['withdraw', 'pool'].includes(context.attachmentType)
|
|
15675
|
+
},
|
|
15603
15676
|
haveProcessing: (context, event) => {
|
|
15604
15677
|
return (context.paymentDetail?.[0]?.processing || []).length > 0
|
|
15605
15678
|
},
|
|
@@ -15628,16 +15701,18 @@ function withdraw_crypto (request) {
|
|
|
15628
15701
|
isOtpRequired: (context, event) => {
|
|
15629
15702
|
return event.data?.status === 'otp-verifying'
|
|
15630
15703
|
},
|
|
15704
|
+
isNewWalletMode: (context, event) => context.siteConfig.walletMode > 0,
|
|
15631
15705
|
},
|
|
15632
15706
|
services: {
|
|
15633
15707
|
fetchInitData: async (context, event) => {
|
|
15634
|
-
const [{ config }, userInfo, paymentDetail = []] = await Promise.all([
|
|
15708
|
+
const [{ config }, userInfo, paymentDetail = [], withdrawRule] = await Promise.all([
|
|
15635
15709
|
request.send(common$1.getConfig({ appSecret })),
|
|
15636
15710
|
request.send(user.getUserInfo()),
|
|
15637
15711
|
request.send(payment.getPaymentDetail({ transferType: 'WITHDRAW' })),
|
|
15712
|
+
request.send(payment.getCurrentWithdrawRule()),
|
|
15638
15713
|
]);
|
|
15639
15714
|
const siteConfig = JSON.parse(window.atob(config));
|
|
15640
|
-
return { siteConfig, userInfo, paymentDetail }
|
|
15715
|
+
return { siteConfig, userInfo, paymentDetail, withdrawRule }
|
|
15641
15716
|
},
|
|
15642
15717
|
fetchPaymentData: async (context, event) => {
|
|
15643
15718
|
const paymentDetail = await request.send(payment.getPaymentDetail({ transferType: 'WITHDRAW' }));
|
|
@@ -15658,7 +15733,7 @@ function withdraw_crypto (request) {
|
|
|
15658
15733
|
})
|
|
15659
15734
|
)
|
|
15660
15735
|
},
|
|
15661
|
-
|
|
15736
|
+
convertFreeCredit: async (context, event) => {
|
|
15662
15737
|
return await request.send(payment.convertFreeCredit({ exchangeType: 1 }))
|
|
15663
15738
|
},
|
|
15664
15739
|
fetchCalculation: async (context, event) => {
|
|
@@ -15681,6 +15756,13 @@ function withdraw_crypto (request) {
|
|
|
15681
15756
|
const code = event.data;
|
|
15682
15757
|
return await request.send(user.otpAcknowledge({ requestId, target, code }))
|
|
15683
15758
|
},
|
|
15759
|
+
pool: async (context, event) => {
|
|
15760
|
+
const { amount } = context;
|
|
15761
|
+
return await request.send(payment.restore({ amount }))
|
|
15762
|
+
},
|
|
15763
|
+
giveUp: async (context, event) => {
|
|
15764
|
+
return await request.send(payment.giveUp())
|
|
15765
|
+
},
|
|
15684
15766
|
},
|
|
15685
15767
|
}
|
|
15686
15768
|
)
|
package/package.json
CHANGED
|
@@ -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: '
|
|
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: '
|
|
87
|
+
src: 'giveUp',
|
|
64
88
|
onDone: {
|
|
65
|
-
target: '
|
|
66
|
-
actions: 'updateWithdrawCondition',
|
|
89
|
+
target: 'gaveUp',
|
|
67
90
|
},
|
|
68
91
|
onError: {
|
|
69
|
-
target: '
|
|
92
|
+
target: 'convertible',
|
|
70
93
|
},
|
|
71
94
|
},
|
|
72
95
|
},
|
|
73
|
-
|
|
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: '
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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'
|
|
26
|
+
attachmentType: null, // null | 'withdraw' | 'pool'
|
|
27
27
|
maximumWithdrawAmount: 0,
|
|
28
28
|
enableWithdrawAmount: 0,
|
|
29
29
|
|