@jetthai/cuora 2.0.0-beta.1 → 2.0.0
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/.claude/commands/sync-ai-prompts.md +93 -0
- package/.claude/settings.local.json +23 -0
- package/.github/copilot-instructions.md +405 -0
- package/.husky/post-checkout +32 -0
- package/.husky/pre-commit +1 -3
- package/.husky/pre-push +36 -0
- package/AGENTS.md +405 -0
- package/AI_PROMPT_SOURCE.md +403 -0
- package/CHANGELOG.md +274 -3
- package/CLAUDE.md +405 -0
- package/GEMINI.md +405 -0
- package/README.md +299 -15
- package/docs/kibana/crypto-way-deposit-amount-bug-analysis.md +1003 -0
- package/docs/kibana/play-providerId-error.md +202 -0
- package/docs/kibana/play-selectedWalletType.md +1 -0
- package/docs/kibana/play-selectedWalletType_2.md +1 -0
- package/docs/kibana/play-selectedWalletType_analysis.md +565 -0
- package/package.json +3 -3
- package/scripts/auto-version.js +68 -0
- package/scripts/auto-version.sh +33 -0
- package/scripts/branch-auto-npm-publish.js +29 -0
- package/scripts/check-version.sh +36 -0
- package/scripts/clean-tags.sh +84 -0
- package/src/api/account.js +0 -1
- package/src/api/activity.js +22 -37
- package/src/api/auth.js +5 -36
- package/src/api/common.js +5 -3
- package/src/api/game.js +0 -10
- package/src/api/payment.js +17 -55
- package/src/api/user.js +10 -16
- package/src/index.js +2 -2
- package/src/machine/activity/activity_cash.js +84 -36
- package/src/machine/activity/cash_rain_activity.js +0 -1
- package/src/machine/activity/continue_deposit_activity.js +0 -1
- package/src/machine/activity/deposit_activity.js +0 -1
- package/src/machine/activity/diamond_shop_activity_cash.js +0 -8
- package/src/machine/activity/fafafa_activity.js +0 -11
- package/src/machine/activity/friend_invite_friends_activity.js +8 -7
- package/src/machine/activity/index.js +0 -12
- package/src/machine/activity/instant_rebate_activity.js +0 -1
- package/src/machine/activity/jackpot.js +0 -1
- package/src/machine/activity/otp_verified_activity.js +0 -1
- package/src/machine/activity/ranking_activity.js +0 -1
- package/src/machine/activity/roulette_activity_v2.js +0 -1
- package/src/machine/activity/sign_in_activity.js +0 -1
- package/src/machine/activity/sign_in_monthly_activity.js +1 -2
- package/src/machine/activity/specify_bets_activity.js +0 -1
- package/src/machine/activity/specify_turnover_activity.js +0 -1
- package/src/machine/activity/time_bomb_activity.js +0 -1
- package/src/machine/activity/vip_card_activity.js +0 -1
- package/src/machine/auth.js +112 -113
- package/src/machine/auth_otp_v3.js +11 -8
- package/src/machine/bank_binding.js +2 -3
- package/src/machine/common.js +14 -112
- package/src/machine/deposit/crypto_bank_cash.js +20 -35
- package/src/machine/deposit/crypto_qrcode_cash.js +26 -64
- package/src/machine/deposit/crypto_way_cash.js +48 -37
- package/src/machine/deposit/direct_cash.js +8 -10
- package/src/machine/deposit/index.js +0 -28
- package/src/machine/deposit/loadcard_cash.js +14 -32
- package/src/machine/deposit/manual_cash.js +18 -28
- package/src/machine/deposit/qrcode_cash.js +15 -32
- package/src/machine/deposit/usdt_cash.js +1 -15
- package/src/machine/deposit/virtual_bank_cash.js +13 -12
- package/src/machine/error.js +7 -1
- package/src/machine/game_betslip.js +0 -1
- package/src/machine/game_favorite_v2.js +0 -1
- package/src/machine/game_info.js +1 -13
- package/src/machine/game_search_cash.js +2 -13
- package/src/machine/game_v2_1.js +42 -166
- package/src/machine/honor_board_cash.js +8 -11
- package/src/machine/inbox.js +43 -105
- package/src/machine/index.js +0 -32
- package/src/machine/leaderboard.js +8 -12
- package/src/machine/navbar.js +1 -3
- package/src/machine/ranking.js +45 -30
- package/src/machine/reward_cash.js +0 -40
- package/src/machine/roulette_v2.js +14 -11
- package/src/machine/setting.js +0 -1
- package/src/machine/side_cash.js +3 -3
- package/src/machine/user_info.js +0 -1
- package/src/machine/user_photo.js +0 -1
- package/src/machine/user_reset_password.js +0 -14
- package/src/machine/user_sign_up.js +46 -61
- package/src/machine/websocket.js +18 -62
- package/src/machine/withdraw/index.js +0 -6
- package/src/machine/withdraw/withdraw_manual_cash.js +59 -39
- package/src/request/config.js +2 -0
- package/src/request/request.js +49 -60
- package/src/util/amount.js +8 -0
- package/src/util/constant.js +0 -1
- package/src/util/err998SentryExtra.js +26 -0
- package/src/util/index.js +2 -4
- package/src/util/paramStore.js +139 -0
- package/src/util/storage.js +3 -4
- package/BREAKING_CHANGES.md +0 -9
- package/resetGitBranch.sh +0 -101
- package/src/lib/fingerprint_v3_11_12.js +0 -11433
- package/src/machine/activity/activity.js +0 -213
- package/src/machine/activity/diamond_shop_activity_fc.js +0 -197
- package/src/machine/activity/diamond_shop_activity_vn.js +0 -179
- package/src/machine/activity/invite_friends_activity.js +0 -115
- package/src/machine/activity/mini_game_activity.js +0 -69
- package/src/machine/activity/return_bonus_activity.js +0 -155
- package/src/machine/auth_otp_v2.js +0 -178
- package/src/machine/bank_binding_amb.js +0 -146
- package/src/machine/bonus.js +0 -76
- package/src/machine/deposit/amb.js +0 -93
- package/src/machine/deposit/crypto_bank.js +0 -340
- package/src/machine/deposit/crypto_qrcode.js +0 -158
- package/src/machine/deposit/crypto_way.js +0 -253
- package/src/machine/deposit/deposit_fc.js +0 -272
- package/src/machine/deposit/direct.js +0 -311
- package/src/machine/deposit/float.js +0 -375
- package/src/machine/deposit/krway.js +0 -152
- package/src/machine/deposit/loadcard_vn.js +0 -352
- package/src/machine/deposit/manual_vn.js +0 -463
- package/src/machine/deposit/qrcode_v2.js +0 -339
- package/src/machine/deposit/usdt.js +0 -163
- package/src/machine/deposit/virtual_bank_vn.js +0 -270
- package/src/machine/deposit/vpay.js +0 -374
- package/src/machine/game_hot_new.js +0 -91
- package/src/machine/game_replay.js +0 -47
- package/src/machine/game_search_v2.js +0 -402
- package/src/machine/honor_board.js +0 -144
- package/src/machine/merge.js +0 -58
- package/src/machine/payment_data.js +0 -87
- package/src/machine/promotions.js +0 -163
- package/src/machine/reward.js +0 -256
- package/src/machine/reward_fc.js +0 -99
- package/src/machine/side.js +0 -160
- package/src/machine/side_v2.js +0 -223
- package/src/machine/vip_table.js +0 -58
- package/src/machine/welcome.js +0 -111
- package/src/machine/withdraw/withdraw_crypto_cash.js +0 -328
- package/src/machine/withdraw/withdraw_krway.js +0 -223
- package/src/machine/withdraw/withdraw_manual.js +0 -541
- package/src/util/deviceToken.js +0 -60
- package/src/util/math.js +0 -4
- package/test/api.behavior.test.js +0 -69
- package/test/api.contract.test.js +0 -18
- package/test/config.test.js +0 -27
- package/test/deviceToken.test.js +0 -139
- package/test/helpers.coverage.test.js +0 -11
- package/test/helpers.js +0 -91
- package/test/index.exports.test.js +0 -14
- package/test/machine.activity.core.coverage.test.js +0 -337
- package/test/machine.activity.gap.coverage.test.js +0 -252
- package/test/machine.activity.more.coverage.test.js +0 -180
- package/test/machine.activity_plus_and_binding_amb.coverage.test.js +0 -201
- package/test/machine.activity_timer_bonus.coverage.test.js +0 -136
- package/test/machine.activity_welcome.low.coverage.test.js +0 -211
- package/test/machine.amb_rewardfc_websocket.more.coverage.test.js +0 -201
- package/test/machine.auth.coverage.test.js +0 -215
- package/test/machine.bank_binding.test.js +0 -143
- package/test/machine.binding_otp_krway.coverage.test.js +0 -223
- package/test/machine.contract.test.js +0 -50
- package/test/machine.crypto_bank.coverage.test.js +0 -270
- package/test/machine.crypto_way.coverage.test.js +0 -108
- package/test/machine.crypto_way_cash.coverage.test.js +0 -114
- package/test/machine.definition.test.js +0 -137
- package/test/machine.deposit.manual.coverage.test.js +0 -365
- package/test/machine.deposit_fc.coverage.test.js +0 -126
- package/test/machine.direct.coverage.test.js +0 -96
- package/test/machine.direct_cash.coverage.test.js +0 -108
- package/test/machine.error.coverage.test.js +0 -37
- package/test/machine.events.test.js +0 -126
- package/test/machine.favorite_jackpot.coverage.test.js +0 -82
- package/test/machine.float.coverage.test.js +0 -136
- package/test/machine.flow.test.js +0 -226
- package/test/machine.game_hot_new_vip_table.coverage.test.js +0 -105
- package/test/machine.game_search_cash.coverage.test.js +0 -195
- package/test/machine.game_search_v2.test.js +0 -199
- package/test/machine.game_user_profile.coverage.test.js +0 -100
- package/test/machine.honor_board.test.js +0 -148
- package/test/machine.inbox.common.coverage.test.js +0 -304
- package/test/machine.loadcard_cash.coverage.test.js +0 -101
- package/test/machine.loadcard_vn.coverage.test.js +0 -122
- package/test/machine.misc.coverage.test.js +0 -361
- package/test/machine.more2.coverage.test.js +0 -261
- package/test/machine.options.execution.test.js +0 -272
- package/test/machine.priority.coverage.test.js +0 -629
- package/test/machine.qrcode_cash.coverage.test.js +0 -107
- package/test/machine.qrcode_v2.coverage.test.js +0 -121
- package/test/machine.regression.test.js +0 -82
- package/test/machine.roulette_v2.test.js +0 -142
- package/test/machine.side_reward_reset.coverage.test.js +0 -220
- package/test/machine.targeted.coverage.test.js +0 -313
- package/test/machine.usdt.coverage.test.js +0 -95
- package/test/machine.usdt_cash.coverage.test.js +0 -73
- package/test/machine.vip_card_activity.test.js +0 -114
- package/test/machine.virtual_bank_cash.coverage.test.js +0 -105
- package/test/machine.virtual_bank_vn.coverage.test.js +0 -105
- package/test/machine.vpay.coverage.test.js +0 -142
- package/test/machine.withdraw_crypto_cash.coverage.test.js +0 -166
- package/test/machine.withdraw_krway.coverage.test.js +0 -123
- package/test/machine.withdraw_manual.coverage.test.js +0 -185
- package/test/machine.withdraw_manual_cash.coverage.test.js +0 -123
- package/test/request.test.js +0 -325
- package/test/util.storage.errors.test.js +0 -47
- package/test/util.test.js +0 -41
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
import { assign, createMachine } from 'xstate'
|
|
2
|
-
import padStart from 'lodash/padStart.js'
|
|
3
|
-
import payment from '../../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
|
-
predictableActionArguments: true,
|
|
12
|
-
initial: 'loading',
|
|
13
|
-
context: {
|
|
14
|
-
paymentDetails: [],
|
|
15
|
-
|
|
16
|
-
cryptos: [],
|
|
17
|
-
sourceAddress: '',
|
|
18
|
-
|
|
19
|
-
amount: null,
|
|
20
|
-
selectedCrypto: null,
|
|
21
|
-
|
|
22
|
-
currentCategory: 'cryptoWay',
|
|
23
|
-
currentPayment: null,
|
|
24
|
-
|
|
25
|
-
calculation: null,
|
|
26
|
-
result: null,
|
|
27
|
-
|
|
28
|
-
// use for wallet mode 4
|
|
29
|
-
promotion: null,
|
|
30
|
-
},
|
|
31
|
-
states: {
|
|
32
|
-
loading: {
|
|
33
|
-
invoke: {
|
|
34
|
-
src: 'fetchPayments',
|
|
35
|
-
onDone: {
|
|
36
|
-
target: 'loaded',
|
|
37
|
-
actions: 'setPayment',
|
|
38
|
-
},
|
|
39
|
-
onError: {
|
|
40
|
-
target: '#crypto_way.fail',
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
loaded: {
|
|
45
|
-
always: [{ target: 'debouncing', cond: 'isCalculable' }],
|
|
46
|
-
},
|
|
47
|
-
debouncing: {
|
|
48
|
-
after: {
|
|
49
|
-
1000: {
|
|
50
|
-
target: 'calculating',
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
calculating: {
|
|
55
|
-
invoke: {
|
|
56
|
-
src: 'fetchCalculation',
|
|
57
|
-
onDone: {
|
|
58
|
-
target: 'calculated',
|
|
59
|
-
actions: 'setCalculation',
|
|
60
|
-
},
|
|
61
|
-
onError: {
|
|
62
|
-
target: 'loaded',
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
calculated: {
|
|
67
|
-
on: {
|
|
68
|
-
SUBMIT: [
|
|
69
|
-
{
|
|
70
|
-
target: 'submitting',
|
|
71
|
-
cond: 'isSubmittable',
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
target: 'pending',
|
|
75
|
-
},
|
|
76
|
-
],
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
pending: {
|
|
80
|
-
on: {
|
|
81
|
-
SUBMIT: {
|
|
82
|
-
target: 'submitting',
|
|
83
|
-
cond: 'isSubmittable',
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
submitting: {
|
|
88
|
-
invoke: {
|
|
89
|
-
src: 'submitDeposit',
|
|
90
|
-
onDone: {
|
|
91
|
-
target: 'submitted',
|
|
92
|
-
actions: 'setResult',
|
|
93
|
-
},
|
|
94
|
-
onError: {
|
|
95
|
-
target: 'submitFail',
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
submitFail: {
|
|
100
|
-
after: {
|
|
101
|
-
0: { target: 'loaded' },
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
submitted: {},
|
|
105
|
-
fail: {},
|
|
106
|
-
},
|
|
107
|
-
on: {
|
|
108
|
-
SET_CRYPTO: {
|
|
109
|
-
target: '.loaded',
|
|
110
|
-
actions: 'setCrypto',
|
|
111
|
-
},
|
|
112
|
-
SET_ADDRESS: {
|
|
113
|
-
actions: 'setAddress',
|
|
114
|
-
},
|
|
115
|
-
SET_AMOUNT: {
|
|
116
|
-
target: '.loaded',
|
|
117
|
-
actions: ['setAmount', 'clearCalculation'],
|
|
118
|
-
},
|
|
119
|
-
INPUT_AMOUNT: {
|
|
120
|
-
target: '.loaded',
|
|
121
|
-
actions: ['inputAmount', 'clearCalculation'],
|
|
122
|
-
},
|
|
123
|
-
CALCULATE: {
|
|
124
|
-
target: '.debouncing',
|
|
125
|
-
actions: 'clearCalculation',
|
|
126
|
-
},
|
|
127
|
-
SET_PROMOTION: {
|
|
128
|
-
actions: 'setPromotion',
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
actions: {
|
|
134
|
-
setPayment: assign((context, event) => {
|
|
135
|
-
const payments = event.data.filter((item) => item.category === context.currentCategory)
|
|
136
|
-
const cryptos = payments?.map((value, i) => {
|
|
137
|
-
return {
|
|
138
|
-
...value,
|
|
139
|
-
label: value?.cryptoOptional[0],
|
|
140
|
-
network: value?.networkName[0],
|
|
141
|
-
icon: value?.channel,
|
|
142
|
-
}
|
|
143
|
-
})
|
|
144
|
-
return {
|
|
145
|
-
cryptos,
|
|
146
|
-
selectedCrypto: cryptos[0],
|
|
147
|
-
currentPayment: cryptos[0],
|
|
148
|
-
}
|
|
149
|
-
}),
|
|
150
|
-
setCrypto: assign((context, event) => {
|
|
151
|
-
const { cryptos } = context
|
|
152
|
-
const selectedCrypto = cryptos.find((crypto) => crypto.label === event.data.label)
|
|
153
|
-
return {
|
|
154
|
-
selectedCrypto: selectedCrypto,
|
|
155
|
-
amount: null,
|
|
156
|
-
calculation: null,
|
|
157
|
-
}
|
|
158
|
-
}),
|
|
159
|
-
setAmount: assign((context, event) => {
|
|
160
|
-
return {
|
|
161
|
-
amount: event.data,
|
|
162
|
-
}
|
|
163
|
-
}),
|
|
164
|
-
inputAmount: assign((context, event) => {
|
|
165
|
-
return { amount: preciseAdd(`${parseFloat(context.amount || 0)}`, `${parseFloat(event.data)}`) }
|
|
166
|
-
}),
|
|
167
|
-
setAddress: assign((context, event) => {
|
|
168
|
-
return {
|
|
169
|
-
sourceAddress: event.data,
|
|
170
|
-
}
|
|
171
|
-
}),
|
|
172
|
-
setCalculation: assign((context, event) => {
|
|
173
|
-
// V2接口轉換中回傳的資料結構不同
|
|
174
|
-
const { data } = event.data
|
|
175
|
-
if (data) {
|
|
176
|
-
return {
|
|
177
|
-
calculation: data,
|
|
178
|
-
}
|
|
179
|
-
} else {
|
|
180
|
-
return {
|
|
181
|
-
calculation: event.data,
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}),
|
|
185
|
-
clearCalculation: assign((context, event) => {
|
|
186
|
-
return {
|
|
187
|
-
calculation: null,
|
|
188
|
-
}
|
|
189
|
-
}),
|
|
190
|
-
setResult: assign((context, event) => {
|
|
191
|
-
return {
|
|
192
|
-
result: event.data,
|
|
193
|
-
}
|
|
194
|
-
}),
|
|
195
|
-
setPromotion: assign((context, event) => {
|
|
196
|
-
const promotion = event.data
|
|
197
|
-
return {
|
|
198
|
-
promotion,
|
|
199
|
-
}
|
|
200
|
-
}),
|
|
201
|
-
},
|
|
202
|
-
guards: {
|
|
203
|
-
isCalculable: (context, event) => {
|
|
204
|
-
const { selectedCrypto, amount } = context
|
|
205
|
-
return selectedCrypto && amount && selectedCrypto?.minimum <= +amount && +amount <= selectedCrypto?.maximum
|
|
206
|
-
},
|
|
207
|
-
isSubmittable: (context, event) => {
|
|
208
|
-
const { selectedCrypto, amount } = context
|
|
209
|
-
return selectedCrypto && amount
|
|
210
|
-
},
|
|
211
|
-
},
|
|
212
|
-
services: {
|
|
213
|
-
fetchPayments: async (context, event) => {
|
|
214
|
-
return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
|
|
215
|
-
},
|
|
216
|
-
fetchCalculation: async (context, event) => {
|
|
217
|
-
const { selectedCrypto, amount, promotion } = context
|
|
218
|
-
return await request.send(
|
|
219
|
-
payment.getCryptoDepositExpectedResult({
|
|
220
|
-
method: selectedCrypto.method,
|
|
221
|
-
amount,
|
|
222
|
-
cryptoCurrency: selectedCrypto.channel,
|
|
223
|
-
promotionsNo: promotion?.activityNo,
|
|
224
|
-
})
|
|
225
|
-
)
|
|
226
|
-
},
|
|
227
|
-
submitDeposit: async (context, event) => {
|
|
228
|
-
const { selectedCrypto, amount } = context
|
|
229
|
-
return await request.send(
|
|
230
|
-
payment.submitDepositTransactionCrypto({
|
|
231
|
-
method: selectedCrypto.method,
|
|
232
|
-
amount: amount,
|
|
233
|
-
cryptoCurrency: selectedCrypto.channel,
|
|
234
|
-
cryptoNetwork: selectedCrypto.network,
|
|
235
|
-
})
|
|
236
|
-
)
|
|
237
|
-
},
|
|
238
|
-
},
|
|
239
|
-
}
|
|
240
|
-
)
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
function preciseAdd(a, b) {
|
|
244
|
-
let aStr = a.toString()
|
|
245
|
-
let bStr = b.toString()
|
|
246
|
-
|
|
247
|
-
let aDecimalPlaces = aStr.split('.')[1] ? aStr.split('.')[1].length : 0
|
|
248
|
-
let bDecimalPlaces = bStr.split('.')[1] ? bStr.split('.')[1].length : 0
|
|
249
|
-
|
|
250
|
-
let factor = Math.pow(10, Math.max(aDecimalPlaces, bDecimalPlaces))
|
|
251
|
-
|
|
252
|
-
return (Math.round(a * factor) + Math.round(b * factor)) / factor
|
|
253
|
-
}
|
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
import { assign, createMachine } from 'xstate'
|
|
2
|
-
import toNumber from 'lodash/toNumber.js'
|
|
3
|
-
import payment from '../../api/payment.js'
|
|
4
|
-
|
|
5
|
-
// const toNumber = require('lodash/toNumber')
|
|
6
|
-
|
|
7
|
-
export default function (request) {
|
|
8
|
-
return createMachine(
|
|
9
|
-
{
|
|
10
|
-
id: 'deposit',
|
|
11
|
-
predictableActionArguments: true,
|
|
12
|
-
initial: 'loading',
|
|
13
|
-
context: {
|
|
14
|
-
cryptos: [],
|
|
15
|
-
networks: [],
|
|
16
|
-
currentCrypto: null,
|
|
17
|
-
currentNetwork: null,
|
|
18
|
-
currentAmount: null,
|
|
19
|
-
calculatedResult: null,
|
|
20
|
-
submittedResult: null,
|
|
21
|
-
bonus: null,
|
|
22
|
-
},
|
|
23
|
-
states: {
|
|
24
|
-
loading: {
|
|
25
|
-
initial: 'bonusStatus',
|
|
26
|
-
states: {
|
|
27
|
-
bonusStatus: {
|
|
28
|
-
invoke: {
|
|
29
|
-
src: 'getPaymentInfo',
|
|
30
|
-
onDone: {
|
|
31
|
-
target: 'fetchingPayments',
|
|
32
|
-
actions: 'setBonus',
|
|
33
|
-
},
|
|
34
|
-
onError: {
|
|
35
|
-
target: '#deposit.loaded',
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
fetchingPayments: {
|
|
40
|
-
invoke: {
|
|
41
|
-
src: 'fetchPayments',
|
|
42
|
-
onDone: {
|
|
43
|
-
target: '#deposit.loaded',
|
|
44
|
-
actions: 'setCryptos',
|
|
45
|
-
},
|
|
46
|
-
onError: {
|
|
47
|
-
target: '#deposit.loaded',
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
loaded: {
|
|
54
|
-
on: {
|
|
55
|
-
SUBMIT: {
|
|
56
|
-
target: 'submitting',
|
|
57
|
-
cond: 'isSubmittable',
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
checking: {
|
|
62
|
-
entry: 'clearCalculatedResult',
|
|
63
|
-
always: [{ target: 'debouncing', cond: 'isCalculable' }, { target: 'loaded' }],
|
|
64
|
-
},
|
|
65
|
-
debouncing: {
|
|
66
|
-
after: {
|
|
67
|
-
1000: {
|
|
68
|
-
target: 'calculating',
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
calculating: {
|
|
73
|
-
invoke: {
|
|
74
|
-
src: 'fetchCalculation',
|
|
75
|
-
onDone: {
|
|
76
|
-
target: 'loaded',
|
|
77
|
-
actions: 'setCalculatedResult',
|
|
78
|
-
},
|
|
79
|
-
onError: {
|
|
80
|
-
target: 'loaded',
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
submitting: {
|
|
85
|
-
invoke: {
|
|
86
|
-
src: 'submitDeposit',
|
|
87
|
-
onDone: {
|
|
88
|
-
target: '#deposit.submitted',
|
|
89
|
-
actions: 'setSubmittedResult',
|
|
90
|
-
},
|
|
91
|
-
onError: {
|
|
92
|
-
target: 'loaded',
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
switchingBonus: {
|
|
97
|
-
invoke: {
|
|
98
|
-
src: 'setBonusSetting',
|
|
99
|
-
onDone: {
|
|
100
|
-
target: 'checking',
|
|
101
|
-
},
|
|
102
|
-
onError: {
|
|
103
|
-
target: 'loaded',
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
submitted: {},
|
|
108
|
-
},
|
|
109
|
-
on: {
|
|
110
|
-
SET_CRYPTO: {
|
|
111
|
-
target: 'checking',
|
|
112
|
-
actions: 'setCrypto',
|
|
113
|
-
cond: 'hasCryptoOptions',
|
|
114
|
-
},
|
|
115
|
-
SET_NETWORK: {
|
|
116
|
-
target: 'checking',
|
|
117
|
-
actions: 'setNetwork',
|
|
118
|
-
cond: 'hasNetworkOptions',
|
|
119
|
-
},
|
|
120
|
-
SET_AMOUNT: {
|
|
121
|
-
target: 'checking',
|
|
122
|
-
actions: 'setAmount',
|
|
123
|
-
},
|
|
124
|
-
TOGGLE_BONUS: {
|
|
125
|
-
target: 'switchingBonus',
|
|
126
|
-
actions: 'toggleBonus',
|
|
127
|
-
},
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
actions: {
|
|
132
|
-
setCryptos: assign((context, event) => {
|
|
133
|
-
return {
|
|
134
|
-
cryptos: event.data.map((crypto) => ({
|
|
135
|
-
...crypto,
|
|
136
|
-
label: crypto.channel,
|
|
137
|
-
value: crypto.method,
|
|
138
|
-
icon: crypto.channel,
|
|
139
|
-
})),
|
|
140
|
-
}
|
|
141
|
-
}),
|
|
142
|
-
setCrypto: assign((context, event) => {
|
|
143
|
-
const { cryptos, currentNetwork } = context
|
|
144
|
-
const method = cryptos.find((crypto) => crypto.method === event.data.value)
|
|
145
|
-
const networks =
|
|
146
|
-
method?.networkName.map((value, i) => {
|
|
147
|
-
return {
|
|
148
|
-
label: method?.networkOptional?.[i],
|
|
149
|
-
value,
|
|
150
|
-
icon: value,
|
|
151
|
-
}
|
|
152
|
-
}) || []
|
|
153
|
-
|
|
154
|
-
const properties = {
|
|
155
|
-
currentCrypto: event.data,
|
|
156
|
-
networks,
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
if (!networks.includes(currentNetwork)) {
|
|
160
|
-
properties.currentNetwork = null
|
|
161
|
-
properties.currentAmount = null
|
|
162
|
-
properties.calculatedResult = null
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
return properties
|
|
166
|
-
}),
|
|
167
|
-
setNetwork: assign((context, event) => {
|
|
168
|
-
return { currentNetwork: event.data }
|
|
169
|
-
}),
|
|
170
|
-
setAmount: assign((context, event) => {
|
|
171
|
-
const currentAmount = event.data
|
|
172
|
-
|
|
173
|
-
const properties = {
|
|
174
|
-
currentAmount,
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
if (!currentAmount) {
|
|
178
|
-
properties.calculatedResult = null
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
return properties
|
|
182
|
-
}),
|
|
183
|
-
setCalculatedResult: assign((context, event) => {
|
|
184
|
-
// V2接口轉換中回傳的資料結構不同
|
|
185
|
-
const { data } = event.data
|
|
186
|
-
if (data) {
|
|
187
|
-
return {
|
|
188
|
-
calculatedResult: data,
|
|
189
|
-
}
|
|
190
|
-
} else {
|
|
191
|
-
return {
|
|
192
|
-
calculatedResult: event.data,
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}),
|
|
196
|
-
setSubmittedResult: assign((context, event) => {
|
|
197
|
-
return {
|
|
198
|
-
submittedResult: event.data,
|
|
199
|
-
}
|
|
200
|
-
}),
|
|
201
|
-
clearCalculatedResult: assign((context, event) => {
|
|
202
|
-
return {
|
|
203
|
-
calculatedResult: null,
|
|
204
|
-
}
|
|
205
|
-
}),
|
|
206
|
-
toggleBonus: assign((context, event) => {
|
|
207
|
-
const { bonus } = context
|
|
208
|
-
return {
|
|
209
|
-
bonus: bonus === 1 ? 0 : 1,
|
|
210
|
-
}
|
|
211
|
-
}),
|
|
212
|
-
setBonus: assign((context, event) => {
|
|
213
|
-
return {
|
|
214
|
-
bonus: event.data,
|
|
215
|
-
}
|
|
216
|
-
}),
|
|
217
|
-
},
|
|
218
|
-
guards: {
|
|
219
|
-
hasCryptoOptions: (context, evnet) => {
|
|
220
|
-
return context.cryptos.length > 0
|
|
221
|
-
},
|
|
222
|
-
hasNetworkOptions: (context, evnet) => {
|
|
223
|
-
return context.networks.length > 0
|
|
224
|
-
},
|
|
225
|
-
isCalculable: (context, event) => {
|
|
226
|
-
const { currentCrypto, currentNetwork, currentAmount } = context
|
|
227
|
-
return currentCrypto && currentNetwork && toNumber(currentAmount)
|
|
228
|
-
},
|
|
229
|
-
isSubmittable: (context, event) => {
|
|
230
|
-
return context.calculatedResult
|
|
231
|
-
},
|
|
232
|
-
isBonusOff: (context, event) => {
|
|
233
|
-
return context.bonus !== 1
|
|
234
|
-
},
|
|
235
|
-
},
|
|
236
|
-
services: {
|
|
237
|
-
fetchPayments: async (context, event) => {
|
|
238
|
-
return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
|
|
239
|
-
},
|
|
240
|
-
fetchCalculation: async (context, event) => {
|
|
241
|
-
const { currentCrypto, currentAmount } = context
|
|
242
|
-
return await request.send(
|
|
243
|
-
payment.getDepositExpectedResult({
|
|
244
|
-
method: currentCrypto.method,
|
|
245
|
-
amount: Number(currentAmount),
|
|
246
|
-
cryptoCurrency: currentCrypto.channel,
|
|
247
|
-
})
|
|
248
|
-
)
|
|
249
|
-
},
|
|
250
|
-
submitDeposit: async (context, event) => {
|
|
251
|
-
const { currentCrypto, currentNetwork, calculatedResult } = context
|
|
252
|
-
return await request.send(
|
|
253
|
-
payment.submitDepositTransactionCrypto({
|
|
254
|
-
method: currentCrypto.method,
|
|
255
|
-
amount: calculatedResult.actualAmount,
|
|
256
|
-
cryptoCurrency: currentCrypto.channel,
|
|
257
|
-
cryptoNetwork: currentNetwork.value,
|
|
258
|
-
})
|
|
259
|
-
)
|
|
260
|
-
},
|
|
261
|
-
setBonusSetting: async (context, event) => {
|
|
262
|
-
const { bonus } = context
|
|
263
|
-
return await request.send(payment.setBonusSetting({ bonus }))
|
|
264
|
-
},
|
|
265
|
-
getPaymentInfo: async (context, event) => {
|
|
266
|
-
const { bonus } = await request.send(payment.getPaymentInfo())
|
|
267
|
-
return bonus
|
|
268
|
-
},
|
|
269
|
-
},
|
|
270
|
-
}
|
|
271
|
-
)
|
|
272
|
-
}
|