@jetthai/cuora 1.0.204 → 1.0.302-dev-1
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/.husky/pre-commit +4 -0
- package/.prettierignore +1 -0
- package/CHANGELOG.md +848 -0
- package/README.md +6 -0
- package/package.json +6 -9
- package/src/api/activity.js +43 -2
- package/src/api/auth.js +22 -7
- package/src/api/common.js +3 -1
- package/src/api/game.js +20 -7
- package/src/api/mailbox.js +9 -5
- package/src/api/payment.js +167 -19
- package/src/api/user.js +7 -0
- package/src/lib/fingerprint.js +9779 -0
- package/src/machine/activity/activity.js +111 -26
- package/src/machine/activity/activity_cash.js +159 -0
- package/src/machine/activity/cash_rain_activity.js +153 -0
- package/src/machine/activity/continue_deposit_activity.js +11 -2
- package/src/machine/activity/deposit_activity.js +13 -4
- package/src/machine/activity/diamond_shop_activity_cash.js +179 -0
- package/src/machine/activity/diamond_shop_activity_vn.js +54 -89
- package/src/machine/activity/fafafa_activity.js +34 -19
- package/src/machine/activity/{affiliate_invite_friends_activity.js → friend_invite_friends_activity.js} +72 -45
- package/src/machine/activity/index.js +22 -4
- package/src/machine/activity/instant_rebate_activity.js +217 -0
- package/src/machine/activity/invite_friends_activity.js +14 -14
- package/src/machine/activity/jackpot.js +74 -0
- package/src/machine/activity/otp_verified_activity.js +74 -0
- package/src/machine/activity/ranking_activity.js +11 -2
- package/src/machine/activity/roulette_activity_v2.js +90 -0
- package/src/machine/activity/sign_in_activity.js +21 -14
- package/src/machine/activity/sign_in_monthly_activity.js +65 -0
- package/src/machine/activity/specify_bets_activity.js +25 -3
- package/src/machine/activity/specify_turnover_activity.js +25 -3
- package/src/machine/activity/time_bomb_activity.js +11 -2
- package/src/machine/activity/vip_card_activity.js +140 -0
- package/src/machine/auth.js +141 -27
- package/src/machine/auth_otp_v2.js +10 -4
- package/src/machine/auth_otp_v3.js +11 -3
- package/src/machine/bank_binding.js +112 -12
- package/src/machine/bank_binding_amb.js +145 -0
- package/src/machine/common.js +113 -25
- package/src/machine/deposit/amb.js +92 -0
- package/src/machine/deposit/crypto.js +50 -29
- package/src/machine/deposit/crypto_bank.js +317 -0
- package/src/machine/deposit/crypto_bank_cash.js +287 -0
- package/src/machine/deposit/crypto_button.js +174 -39
- package/src/machine/deposit/crypto_cash.js +255 -0
- package/src/machine/deposit/crypto_qrcode.js +148 -0
- package/src/machine/deposit/crypto_qrcode_cash.js +131 -0
- package/src/machine/deposit/crypto_way.js +239 -0
- package/src/machine/deposit/crypto_way_cash.js +256 -0
- package/src/machine/deposit/deposit_fc.js +8 -5
- package/src/machine/deposit/direct.js +111 -16
- package/src/machine/deposit/direct_cash.js +217 -0
- package/src/machine/deposit/float.js +366 -0
- package/src/machine/deposit/index.js +43 -2
- package/src/machine/deposit/krway.js +151 -0
- package/src/machine/deposit/loadcard_cash.js +207 -0
- package/src/machine/deposit/loadcard_vn.js +191 -43
- package/src/machine/deposit/manual_cash.js +356 -0
- package/src/machine/deposit/manual_vn.js +182 -60
- package/src/machine/deposit/qrcode_cash.js +217 -0
- package/src/machine/deposit/qrcode_v2.js +285 -52
- package/src/machine/deposit/usdt.js +144 -0
- package/src/machine/deposit/usdt_cash.js +138 -0
- package/src/machine/deposit/vpay.js +359 -0
- package/src/machine/game_favorite_v2.js +70 -28
- package/src/machine/game_info.js +57 -0
- package/src/machine/game_search_cash.js +390 -0
- package/src/machine/game_search_v2.js +64 -24
- package/src/machine/game_v2_1.js +662 -0
- package/src/machine/honor_board_cash.js +63 -0
- package/src/machine/inbox.js +259 -34
- package/src/machine/index.js +24 -17
- package/src/machine/leaderboard.js +31 -8
- package/src/machine/navbar.js +57 -0
- package/src/machine/promotions.js +171 -0
- package/src/machine/reward.js +74 -7
- package/src/machine/reward_cash.js +219 -0
- package/src/machine/roulette_v2.js +276 -0
- package/src/machine/setting.js +5 -2
- package/src/machine/side_cash.js +110 -0
- package/src/machine/side_v2.js +33 -28
- package/src/machine/user_photo.js +65 -0
- package/src/machine/user_sign_up.js +117 -17
- package/src/machine/withdraw/index.js +23 -0
- package/src/machine/{withdraw_vn.js → withdraw/withdraw_amb.js} +146 -78
- package/src/machine/{withdraw_crypto.js → withdraw/withdraw_crypto.js} +220 -69
- package/src/machine/withdraw/withdraw_crypto2.js +540 -0
- package/src/machine/withdraw/withdraw_crypto_cash.js +319 -0
- package/src/machine/{withdraw_fc.js → withdraw/withdraw_fc.js} +2 -2
- package/src/machine/withdraw/withdraw_krway.js +207 -0
- package/src/machine/withdraw/withdraw_manual.js +595 -0
- package/src/machine/withdraw/withdraw_manual_cash.js +303 -0
- package/src/machine/withdraw/withdraw_vn.js +533 -0
- package/src/machine/withdraw/withdraw_vn2.js +548 -0
- package/src/request/request.js +10 -5
- package/src/util/constant.js +19 -1
- package/src/util/deviceToken.js +18 -8
- package/src/util/index.js +2 -1
- package/src/util/math.js +4 -0
- package/src/util/storage.js +22 -22
- package/dist/bundle.mjs +0 -18462
- package/rollup.config.js +0 -16
- package/src/machine/auth_otp.js +0 -201
- package/src/machine/deposit/qrcode_vn.js +0 -206
- package/src/machine/game.js +0 -285
- package/src/machine/game_favorite.js +0 -123
- package/src/machine/game_search.js +0 -244
- package/src/machine/game_v2.js +0 -356
|
@@ -0,0 +1,148 @@
|
|
|
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, redirect } = event.data
|
|
105
|
+
const result = {
|
|
106
|
+
action,
|
|
107
|
+
cdtime,
|
|
108
|
+
accountNumber,
|
|
109
|
+
currency,
|
|
110
|
+
network,
|
|
111
|
+
name,
|
|
112
|
+
qrcode,
|
|
113
|
+
redirect,
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return {
|
|
117
|
+
result,
|
|
118
|
+
resultMap: {
|
|
119
|
+
...resultMap,
|
|
120
|
+
[selectedCrypto.network]: result,
|
|
121
|
+
},
|
|
122
|
+
}
|
|
123
|
+
}),
|
|
124
|
+
},
|
|
125
|
+
guards: {
|
|
126
|
+
isFound: (context, event) => {
|
|
127
|
+
const { resultMap, selectedCrypto } = context
|
|
128
|
+
return resultMap[selectedCrypto.network]
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
services: {
|
|
132
|
+
fetchPaymentDetail: async (context, event) => {
|
|
133
|
+
return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
|
|
134
|
+
},
|
|
135
|
+
submitDeposit: async (context, event) => {
|
|
136
|
+
const { currentPayment, selectedCrypto } = context
|
|
137
|
+
return await request.send(
|
|
138
|
+
payment.submitDepositTransactionCrypto({
|
|
139
|
+
method: currentPayment.method,
|
|
140
|
+
cryptoCurrency: currentPayment.channel,
|
|
141
|
+
cryptoNetwork: selectedCrypto.network,
|
|
142
|
+
})
|
|
143
|
+
)
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
}
|
|
147
|
+
)
|
|
148
|
+
}
|
|
@@ -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, action, currency, network, qrcode, forexRate, redirect } = event.data
|
|
97
|
+
const result = { accountNumber, action, currency, network, qrcode, forexRate, redirect }
|
|
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,239 @@
|
|
|
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
|
+
INPUT_AMOUNT: {
|
|
114
|
+
target: '.loaded',
|
|
115
|
+
actions: ['inputAmount', 'clearCalculation'],
|
|
116
|
+
},
|
|
117
|
+
CALCULATE: {
|
|
118
|
+
target: '.debouncing',
|
|
119
|
+
actions: 'clearCalculation',
|
|
120
|
+
},
|
|
121
|
+
SET_PROMOTION: {
|
|
122
|
+
actions: 'setPromotion',
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
actions: {
|
|
128
|
+
setPayment: assign((context, event) => {
|
|
129
|
+
const payments = event.data.filter((item) => item.category === context.currentCategory)
|
|
130
|
+
const cryptos = payments?.map((value, i) => {
|
|
131
|
+
return {
|
|
132
|
+
...value,
|
|
133
|
+
label: value?.cryptoOptional[0],
|
|
134
|
+
network: value?.networkName[0],
|
|
135
|
+
icon: value?.channel,
|
|
136
|
+
}
|
|
137
|
+
})
|
|
138
|
+
return {
|
|
139
|
+
cryptos,
|
|
140
|
+
selectedCrypto: cryptos[0],
|
|
141
|
+
currentPayment: cryptos[0],
|
|
142
|
+
}
|
|
143
|
+
}),
|
|
144
|
+
setCrypto: assign((context, event) => {
|
|
145
|
+
const { cryptos } = context
|
|
146
|
+
const selectedCrypto = cryptos.find((crypto) => crypto.label === event.data.label)
|
|
147
|
+
return {
|
|
148
|
+
selectedCrypto: selectedCrypto,
|
|
149
|
+
amount: null,
|
|
150
|
+
calculation: null,
|
|
151
|
+
}
|
|
152
|
+
}),
|
|
153
|
+
setAmount: assign((context, event) => {
|
|
154
|
+
return {
|
|
155
|
+
amount: event.data,
|
|
156
|
+
}
|
|
157
|
+
}),
|
|
158
|
+
inputAmount: assign((context, event) => {
|
|
159
|
+
return { amount: preciseAdd(`${parseFloat(context.amount || 0)}`, `${parseFloat(event.data)}`) }
|
|
160
|
+
}),
|
|
161
|
+
setAddress: assign((context, event) => {
|
|
162
|
+
return {
|
|
163
|
+
sourceAddress: event.data,
|
|
164
|
+
}
|
|
165
|
+
}),
|
|
166
|
+
setCalculation: assign((context, event) => {
|
|
167
|
+
return {
|
|
168
|
+
calculation: event.data,
|
|
169
|
+
}
|
|
170
|
+
}),
|
|
171
|
+
clearCalculation: assign((context, event) => {
|
|
172
|
+
return {
|
|
173
|
+
calculation: null,
|
|
174
|
+
}
|
|
175
|
+
}),
|
|
176
|
+
setResult: assign((context, event) => {
|
|
177
|
+
return {
|
|
178
|
+
result: event.data,
|
|
179
|
+
}
|
|
180
|
+
}),
|
|
181
|
+
setPromotion: assign((context, event) => {
|
|
182
|
+
const promotion = event.data
|
|
183
|
+
return {
|
|
184
|
+
promotion,
|
|
185
|
+
}
|
|
186
|
+
}),
|
|
187
|
+
},
|
|
188
|
+
guards: {
|
|
189
|
+
isCalculable: (context, event) => {
|
|
190
|
+
const { selectedCrypto, amount } = context
|
|
191
|
+
return selectedCrypto && amount && selectedCrypto?.minimum <= +amount && +amount <= selectedCrypto?.maximum
|
|
192
|
+
},
|
|
193
|
+
isSubmittable: (context, event) => {
|
|
194
|
+
const { selectedCrypto, amount } = context
|
|
195
|
+
return selectedCrypto && amount
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
services: {
|
|
199
|
+
fetchPayments: async (context, event) => {
|
|
200
|
+
return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
|
|
201
|
+
},
|
|
202
|
+
fetchCalculation: async (context, event) => {
|
|
203
|
+
const { selectedCrypto, amount, promotion } = context
|
|
204
|
+
return await request.send(
|
|
205
|
+
payment.getCryptoDepositExpectedResult({
|
|
206
|
+
method: selectedCrypto.method,
|
|
207
|
+
amount,
|
|
208
|
+
cryptoCurrency: selectedCrypto.channel,
|
|
209
|
+
promotionsNo: promotion?.activityNo,
|
|
210
|
+
})
|
|
211
|
+
)
|
|
212
|
+
},
|
|
213
|
+
submitDeposit: async (context, event) => {
|
|
214
|
+
const { selectedCrypto, amount } = context
|
|
215
|
+
return await request.send(
|
|
216
|
+
payment.submitDepositTransactionCrypto({
|
|
217
|
+
method: selectedCrypto.method,
|
|
218
|
+
amount: amount,
|
|
219
|
+
cryptoCurrency: selectedCrypto.channel,
|
|
220
|
+
cryptoNetwork: selectedCrypto.network,
|
|
221
|
+
})
|
|
222
|
+
)
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
}
|
|
226
|
+
)
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function preciseAdd(a, b) {
|
|
230
|
+
let aStr = a.toString()
|
|
231
|
+
let bStr = b.toString()
|
|
232
|
+
|
|
233
|
+
let aDecimalPlaces = aStr.split('.')[1] ? aStr.split('.')[1].length : 0
|
|
234
|
+
let bDecimalPlaces = bStr.split('.')[1] ? bStr.split('.')[1].length : 0
|
|
235
|
+
|
|
236
|
+
let factor = Math.pow(10, Math.max(aDecimalPlaces, bDecimalPlaces))
|
|
237
|
+
|
|
238
|
+
return (Math.round(a * factor) + Math.round(b * factor)) / factor
|
|
239
|
+
}
|