@jetthai/cuora 1.1.488-dev.1 → 1.2.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/.husky/pre-commit +3 -1
- package/.prettierignore +1 -2
- package/CHANGELOG.md +0 -746
- package/README.md +15 -299
- package/package.json +3 -6
- package/resetGitBranch.sh +101 -0
- package/src/api/activity.js +39 -24
- package/src/api/auth.js +35 -4
- package/src/api/common.js +1 -8
- package/src/api/game.js +10 -0
- package/src/api/index.js +1 -3
- package/src/api/payment.js +55 -18
- package/src/api/user.js +16 -11
- package/src/index.js +2 -2
- package/src/lib/fingerprint_v3_11_12.js +11433 -0
- package/src/machine/activity/activity.js +209 -0
- package/src/machine/activity/activity_cash.js +18 -71
- package/src/machine/activity/diamond_shop_activity_cash.js +1 -0
- package/src/machine/activity/diamond_shop_activity_fc.js +196 -0
- package/src/machine/activity/diamond_shop_activity_vn.js +178 -0
- package/src/machine/activity/fafafa_activity.js +10 -0
- package/src/machine/activity/index.js +12 -0
- package/src/machine/activity/invite_friends_activity.js +114 -0
- package/src/machine/activity/mini_game_activity.js +68 -0
- package/src/machine/activity/return_bonus_activity.js +153 -0
- package/src/machine/activity/roulette_activity_v2.js +0 -5
- package/src/machine/auth.js +140 -192
- package/src/machine/auth_otp_v2.js +177 -0
- package/src/machine/auth_otp_v3.js +32 -111
- package/src/machine/bank_binding.js +2 -2
- package/src/machine/bank_binding_amb.js +145 -0
- package/src/machine/bonus.js +75 -0
- package/src/machine/common.js +91 -27
- package/src/machine/deposit/amb.js +92 -0
- package/src/machine/deposit/crypto_bank.js +325 -0
- package/src/machine/deposit/crypto_bank_cash.js +8 -19
- package/src/machine/deposit/crypto_qrcode.js +148 -0
- package/src/machine/deposit/crypto_qrcode_cash.js +41 -26
- package/src/machine/deposit/crypto_way.js +247 -0
- package/src/machine/deposit/crypto_way_cash.js +32 -52
- package/src/machine/deposit/deposit_fc.js +271 -0
- package/src/machine/deposit/direct.js +310 -0
- package/src/machine/deposit/direct_cash.js +9 -8
- package/src/machine/deposit/float.js +374 -0
- package/src/machine/deposit/index.js +28 -0
- package/src/machine/deposit/krway.js +151 -0
- package/src/machine/deposit/loadcard_cash.js +31 -14
- package/src/machine/deposit/loadcard_vn.js +351 -0
- package/src/machine/deposit/manual_cash.js +10 -8
- package/src/machine/deposit/manual_vn.js +458 -0
- package/src/machine/deposit/qrcode_cash.js +30 -14
- package/src/machine/deposit/qrcode_v2.js +338 -0
- package/src/machine/deposit/usdt.js +144 -0
- package/src/machine/deposit/virtual_bank_cash.js +2 -5
- package/src/machine/deposit/virtual_bank_vn.js +269 -0
- package/src/machine/deposit/vpay.js +367 -0
- package/src/machine/error.js +0 -7
- package/src/machine/game_hot_new.js +79 -0
- package/src/machine/game_info.js +12 -5
- package/src/machine/game_replay.js +46 -0
- package/src/machine/game_search_v2.js +401 -0
- package/src/machine/game_v2_1.js +88 -58
- package/src/machine/honor_board.js +132 -0
- package/src/machine/honor_board_cash.js +18 -15
- package/src/machine/inbox.js +12 -0
- package/src/machine/index.js +32 -0
- package/src/machine/leaderboard.js +11 -8
- package/src/machine/merge.js +57 -0
- package/src/machine/payment_data.js +86 -0
- package/src/machine/promotions.js +170 -0
- package/src/machine/ranking.js +25 -43
- package/src/machine/reward.js +255 -0
- package/src/machine/reward_cash.js +41 -2
- package/src/machine/reward_fc.js +98 -0
- package/src/machine/roulette_v2.js +25 -20
- package/src/machine/side.js +154 -0
- package/src/machine/side_cash.js +2 -3
- package/src/machine/side_v2.js +209 -0
- package/src/machine/user_reset_password.js +15 -4
- package/src/machine/user_sign_up.js +60 -49
- package/src/machine/vip_table.js +57 -0
- package/src/machine/websocket.js +325 -378
- package/src/machine/welcome.js +110 -0
- package/src/machine/withdraw/index.js +6 -0
- package/src/machine/withdraw/withdraw_crypto_cash.js +327 -0
- package/src/machine/withdraw/withdraw_krway.js +222 -0
- package/src/machine/withdraw/withdraw_manual.js +533 -0
- package/src/machine/withdraw/withdraw_manual_cash.js +43 -74
- package/src/request/config.js +0 -2
- package/src/request/request.js +64 -231
- package/src/util/constant.js +2 -12
- package/src/util/deviceToken.js +59 -0
- package/src/util/index.js +4 -2
- package/src/util/math.js +4 -0
- package/.claude/commands/sync-ai-prompts.md +0 -180
- package/.claude/settings.local.json +0 -25
- package/.github/copilot-instructions.md +0 -459
- package/.husky/post-checkout +0 -32
- package/.husky/pre-push +0 -36
- package/AGENTS.md +0 -459
- package/AI_PROMPT_SOURCE.md +0 -457
- package/CLAUDE.md +0 -459
- package/GEMINI.md +0 -459
- package/docs/kibana/crypto-way-deposit-amount-bug-analysis.md +0 -1003
- package/docs/kibana/play-providerId-error.md +0 -202
- package/docs/kibana/play-selectedWalletType.md +0 -1
- package/docs/kibana/play-selectedWalletType_2.md +0 -1
- package/docs/kibana/play-selectedWalletType_analysis.md +0 -565
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/branch-transfer.md +0 -14
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/cash-module-preparation.json +0 -40
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/cash-module-verification.md +0 -41
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/implementation-ledger.md +0 -87
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/module-report.md +0 -73
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/plan.md +0 -309
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/test-cases.md +0 -245
- package/docs/my-claude/feat-sharon-JT-1791180540-onesignal/transfer.md +0 -9
- package/e2e/feature-map.md +0 -19
- package/prepare-for-pr/JT-1776243420.md +0 -85
- package/prepare-for-pr/TI-16026/STATE.md +0 -18
- package/prepare-for-pr/TI-16026/after-prepare-authorization.md +0 -3
- package/prepare-for-pr/TI-16026/analysis.md +0 -38
- package/prepare-for-pr/TI-16026/answer-analyze-01.md +0 -1
- package/prepare-for-pr/TI-16026/answer-commit-01.md +0 -2
- package/prepare-for-pr/TI-16026/answer-commit-02.md +0 -1
- package/prepare-for-pr/TI-16026/bundle.json +0 -18
- package/prepare-for-pr/TI-16026/checklist.md +0 -196
- package/prepare-for-pr/TI-16026/checklist.unit-test-original.md +0 -39
- package/prepare-for-pr/TI-16026/claude-after-model +0 -1
- package/prepare-for-pr/TI-16026/claude-commit-session +0 -1
- package/prepare-for-pr/TI-16026/claude-harvest-session +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/01-analyze.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/01-analyze.out +0 -2
- package/prepare-for-pr/TI-16026/claude-hops/02-analyze.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/02-analyze.out +0 -4
- package/prepare-for-pr/TI-16026/claude-hops/03-dev.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/03-dev.out +0 -4
- package/prepare-for-pr/TI-16026/claude-hops/04-dev.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/04-dev.out +0 -4
- package/prepare-for-pr/TI-16026/claude-hops/05-dev.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/05-dev.out +0 -3
- package/prepare-for-pr/TI-16026/claude-hops/06-after.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/06-after.out +0 -2
- package/prepare-for-pr/TI-16026/claude-hops/07-commit.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/07-commit.out +0 -2
- package/prepare-for-pr/TI-16026/claude-hops/08-commit.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/08-commit.out +0 -2
- package/prepare-for-pr/TI-16026/claude-hops/09-commit.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/09-commit.out +0 -8
- package/prepare-for-pr/TI-16026/claude-hops/10-harvest.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/10-harvest.out +0 -3
- package/prepare-for-pr/TI-16026/claude-hops/11-harvest.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/11-harvest.out +0 -3
- package/prepare-for-pr/TI-16026/commit-note.md +0 -5
- package/prepare-for-pr/TI-16026/evidence-index.json +0 -215
- package/prepare-for-pr/TI-16026/feature-map.before.md +0 -61
- package/prepare-for-pr/TI-16026/harvest-redaction.json +0 -34
- package/prepare-for-pr/TI-16026/harvest-redaction.out +0 -37
- package/prepare-for-pr/TI-16026/harvest.md +0 -46
- package/prepare-for-pr/TI-16026/lessons.md +0 -5
- package/prepare-for-pr/TI-16026/note-harvest-redaction.md +0 -1
- package/prepare-for-pr/TI-16026/open-questions.md +0 -6
- package/prepare-for-pr/TI-16026/publish.md +0 -32
- package/prepare-for-pr/TI-16026/review-convergence-response.md +0 -3
- package/prepare-for-pr/TI-16026/review-input/scope.md +0 -18
- package/prepare-for-pr/TI-16026/review-log.md +0 -57
- package/prepare-for-pr/TI-16026/review-notes.md +0 -97
- package/prepare-for-pr/TI-16026/review-response-r1.md +0 -7
- package/prepare-for-pr/TI-16026/self-test-report.md +0 -67
- package/prepare-for-pr/TI-16026/spec-proposal.md +0 -34
- package/prepare-for-pr/TI-16026/spec-snapshot.md +0 -291
- package/prepare-for-pr/TI-16026/state-log.md +0 -57
- package/prepare-for-pr/TI-16026/user-messages/01.md +0 -12
- package/prepare-for-pr/TI-16026/user-messages/02.md +0 -20
- package/prepare-for-pr/TI-16026/user-messages/03.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/04.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/05.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/06.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/07.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/08.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/09.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/10.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/11.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/12.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/13.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/14.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/15.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/16.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/17.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/18.md +0 -10
- package/prepare-for-pr/TI-16026/user-messages/19.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/20.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/21.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/22.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/23.md +0 -8
- package/prepare-for-pr/TI-16026/user-messages/24.md +0 -24
- package/prepare-for-pr/TI-16026/user-question.md +0 -24
- package/prepare-for-pr/TI-16026/verify/metrics-check.json +0 -13
- package/prepare-for-pr/TI-16026/verify/redaction.json +0 -38
- package/prepare-for-pr/TI-16026/verify/row-closure.json +0 -45
- package/prepare-for-pr/TI-16026/verify/s04-ws-capture.md +0 -23
- package/prepare-for-pr/TI-16026/verify-after.md +0 -23
- package/prepare-for-pr/TI-16026/verify.json +0 -80
- package/prepare-for-pr/TI-16026.md +0 -408
- package/scripts/auto-version.js +0 -69
- package/scripts/auto-version.sh +0 -33
- package/scripts/branch-auto-npm-publish.js +0 -36
- package/scripts/check-version.sh +0 -36
- package/scripts/clean-tags.sh +0 -84
- package/src/api/account.js +0 -7
- package/src/api/otp.js +0 -5
- package/src/util/amount.js +0 -8
- package/src/util/err998SentryExtra.js +0 -26
- package/src/util/paramStore.js +0 -139
- package/src/util/socketPolicy.js +0 -57
- package/src/util/tokenStore.js +0 -44
- package/test/auth_otp_v3.test.js +0 -323
- package/test/auth_self_timeout.test.js +0 -171
- package/test/request_self.test.js +0 -288
- package/test/withdraw_manual_cash.test.js +0 -149
- package/tests/session.test.mjs +0 -177
- package/tests/websocket.test.mjs +0 -779
package/src/machine/common.js
CHANGED
|
@@ -3,10 +3,9 @@ import { assign, createMachine } from 'xstate'
|
|
|
3
3
|
import pickBy from 'lodash/pickBy.js'
|
|
4
4
|
import api from '../api/common.js'
|
|
5
5
|
import storage from '../util/storage.js'
|
|
6
|
-
import { readParam, writeParam, AC_KEYS, FC_KEYS } from '../util/paramStore.js'
|
|
7
6
|
|
|
8
7
|
export default function (request) {
|
|
9
|
-
const { appSecret,
|
|
8
|
+
const { appSecret, defaultChannel, defaultSubchannel } = request.config
|
|
10
9
|
return createMachine(
|
|
11
10
|
{
|
|
12
11
|
id: 'common',
|
|
@@ -34,6 +33,10 @@ export default function (request) {
|
|
|
34
33
|
broadcastList: null,
|
|
35
34
|
mailBoxInfo: null,
|
|
36
35
|
promotions: [],
|
|
36
|
+
normalBroadcast: null,
|
|
37
|
+
sentNormalBroadcastList: [],
|
|
38
|
+
channel: null,
|
|
39
|
+
subchannel: null,
|
|
37
40
|
affiliateCode: null,
|
|
38
41
|
defaultAffiliateCode: null,
|
|
39
42
|
friendCode: null,
|
|
@@ -52,7 +55,7 @@ export default function (request) {
|
|
|
52
55
|
},
|
|
53
56
|
},
|
|
54
57
|
fetching: {
|
|
55
|
-
entry: ['setUA', 'setAgent', 'setPixel', 'setKPixel'
|
|
58
|
+
entry: ['setUA', 'setAgent', 'setPixel', 'setKPixel'],
|
|
56
59
|
invoke: {
|
|
57
60
|
src: 'fetchConfig',
|
|
58
61
|
onDone: [
|
|
@@ -119,9 +122,6 @@ export default function (request) {
|
|
|
119
122
|
},
|
|
120
123
|
},
|
|
121
124
|
on: {
|
|
122
|
-
REFRESH_FEEDS: {
|
|
123
|
-
target: '.updating',
|
|
124
|
-
},
|
|
125
125
|
ENTER_GAME_PAUSE: {
|
|
126
126
|
target: '.idle',
|
|
127
127
|
actions: 'resetByEnterGame',
|
|
@@ -157,6 +157,39 @@ export default function (request) {
|
|
|
157
157
|
},
|
|
158
158
|
},
|
|
159
159
|
},
|
|
160
|
+
broadcast: {
|
|
161
|
+
initial: 'idle',
|
|
162
|
+
states: {
|
|
163
|
+
idle: {
|
|
164
|
+
on: {
|
|
165
|
+
START_BROADCAST: {
|
|
166
|
+
target: 'picking',
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
picking: {
|
|
171
|
+
after: {
|
|
172
|
+
5000: {
|
|
173
|
+
target: 'display',
|
|
174
|
+
actions: 'setBroadcast',
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
display: {
|
|
179
|
+
after: {
|
|
180
|
+
5000: {
|
|
181
|
+
target: 'picking',
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
on: {
|
|
187
|
+
RESET_BROADCAST: {
|
|
188
|
+
target: '.idle',
|
|
189
|
+
actions: 'resetBroadcast',
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
},
|
|
160
193
|
},
|
|
161
194
|
},
|
|
162
195
|
{
|
|
@@ -204,18 +237,6 @@ export default function (request) {
|
|
|
204
237
|
isMobile: userAgent?.device?.type,
|
|
205
238
|
}
|
|
206
239
|
}),
|
|
207
|
-
setFbclid: assign(() => {
|
|
208
|
-
const urlParams = new URLSearchParams(window.location.search)
|
|
209
|
-
const fbclid = urlParams.get('fbclid') || ''
|
|
210
|
-
if (fbclid !== '') {
|
|
211
|
-
const timestamp = Date.now()
|
|
212
|
-
const cookieRecord = 'fb.1.' + timestamp + '.' + fbclid
|
|
213
|
-
document.cookie = `_fbc=${cookieRecord}; path=/; max-age=${60 * 60 * 24 * 7}`
|
|
214
|
-
}
|
|
215
|
-
return {
|
|
216
|
-
fbclid,
|
|
217
|
-
}
|
|
218
|
-
}),
|
|
219
240
|
setPixel: assign(() => {
|
|
220
241
|
let urlParams = new URLSearchParams(window.location.search)
|
|
221
242
|
const pix = urlParams.get('pix') || storage.get('pix') || ''
|
|
@@ -242,17 +263,40 @@ export default function (request) {
|
|
|
242
263
|
kpix,
|
|
243
264
|
}
|
|
244
265
|
}),
|
|
245
|
-
setAgent: assign(() => {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
266
|
+
setAgent: assign((context, event) => {
|
|
267
|
+
if (window.CC_JSB === true) {
|
|
268
|
+
// is cocos native app
|
|
269
|
+
return
|
|
270
|
+
} else {
|
|
271
|
+
let urlParams = new URLSearchParams(window.location.search)
|
|
272
|
+
const channel = urlParams.get('channel') || storage.get('channel') || defaultChannel || 'official'
|
|
273
|
+
const subchannel = urlParams.get('subchannel') || storage.get('subchannel') || defaultSubchannel || 'pwa'
|
|
274
|
+
const affiliateCode = urlParams.get('ac') || urlParams.get('referralCode') || storage.get('ac') || storage.get('referralCode')
|
|
275
|
+
const friendCode = urlParams.get('fc') || urlParams.get('affiliate') || storage.get('fc') || storage.get('affiliate')
|
|
249
276
|
|
|
250
|
-
|
|
251
|
-
|
|
277
|
+
storage.set('channel', channel, {
|
|
278
|
+
path: '/',
|
|
279
|
+
maxAge: 60 * 60 * 24 * 7,
|
|
280
|
+
})
|
|
281
|
+
storage.set('subchannel', subchannel, {
|
|
282
|
+
path: '/',
|
|
283
|
+
maxAge: 60 * 60 * 24 * 7,
|
|
284
|
+
})
|
|
285
|
+
storage.set('ac', affiliateCode, {
|
|
286
|
+
path: '/',
|
|
287
|
+
maxAge: 60 * 60 * 24 * 7,
|
|
288
|
+
})
|
|
289
|
+
storage.set('fc', friendCode, {
|
|
290
|
+
path: '/',
|
|
291
|
+
maxAge: 60 * 60 * 24 * 7,
|
|
292
|
+
})
|
|
252
293
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
294
|
+
return {
|
|
295
|
+
channel,
|
|
296
|
+
subchannel,
|
|
297
|
+
affiliateCode,
|
|
298
|
+
friendCode,
|
|
299
|
+
}
|
|
256
300
|
}
|
|
257
301
|
}),
|
|
258
302
|
clearAnnouncements: assign((context, event) => {
|
|
@@ -271,6 +315,26 @@ export default function (request) {
|
|
|
271
315
|
}
|
|
272
316
|
return { broadcastList, mailBoxInfo }
|
|
273
317
|
}),
|
|
318
|
+
setBroadcast: assign((context, event) => {
|
|
319
|
+
const { broadcastList, sentNormalBroadcastList, normalBroadcast } = context
|
|
320
|
+
let sentNormalList = sentNormalBroadcastList
|
|
321
|
+
if (normalBroadcast) {
|
|
322
|
+
sentNormalList = [...sentNormalBroadcastList, normalBroadcast]
|
|
323
|
+
}
|
|
324
|
+
const nextNormalBroadcast = broadcastList?.broadcasts?.find((broadcast) => {
|
|
325
|
+
return broadcast.type === '0' && !sentNormalList.some((item) => item.broadcast_id === broadcast.broadcast_id)
|
|
326
|
+
})
|
|
327
|
+
return {
|
|
328
|
+
normalBroadcast: nextNormalBroadcast,
|
|
329
|
+
sentNormalBroadcastList: sentNormalList,
|
|
330
|
+
}
|
|
331
|
+
}),
|
|
332
|
+
resetBroadcast: assign((context, event) => {
|
|
333
|
+
return {
|
|
334
|
+
normalBroadcast: null,
|
|
335
|
+
sentNormalBroadcastList: [],
|
|
336
|
+
}
|
|
337
|
+
}),
|
|
274
338
|
resetByEnterGame: assign((context, event) => {
|
|
275
339
|
return {
|
|
276
340
|
isPlaying: true,
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { assign, createMachine } from 'xstate'
|
|
2
|
+
import payment from '../../api/payment.js'
|
|
3
|
+
|
|
4
|
+
export default function (request) {
|
|
5
|
+
return createMachine(
|
|
6
|
+
{
|
|
7
|
+
id: 'amb',
|
|
8
|
+
initial: 'loading',
|
|
9
|
+
context: {
|
|
10
|
+
bankList: [],
|
|
11
|
+
userAccount: {},
|
|
12
|
+
houseAccountName: null,
|
|
13
|
+
houseAccountNumber: null,
|
|
14
|
+
houseBankName: null,
|
|
15
|
+
method: 'amb',
|
|
16
|
+
},
|
|
17
|
+
states: {
|
|
18
|
+
loading: {
|
|
19
|
+
initial: 'checkingUserAccount',
|
|
20
|
+
states: {
|
|
21
|
+
checkingUserAccount: {
|
|
22
|
+
invoke: {
|
|
23
|
+
src: 'fetchPaymentInfo',
|
|
24
|
+
onDone: [
|
|
25
|
+
{
|
|
26
|
+
target: 'initializing',
|
|
27
|
+
actions: 'setUserAccount',
|
|
28
|
+
cond: 'hasUserAccount',
|
|
29
|
+
},
|
|
30
|
+
{ target: '#amb.accountUnbound' },
|
|
31
|
+
],
|
|
32
|
+
onError: {
|
|
33
|
+
target: '#amb.unavailable',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
initializing: {
|
|
38
|
+
invoke: {
|
|
39
|
+
src: 'initialize',
|
|
40
|
+
onDone: { target: '#amb.finish', actions: 'setInitialization' },
|
|
41
|
+
onError: {
|
|
42
|
+
target: '#amb.unavailable',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
finish: {},
|
|
49
|
+
accountUnbound: {},
|
|
50
|
+
unavailable: {},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
actions: {
|
|
55
|
+
setUserAccount: assign((context, event) => {
|
|
56
|
+
return {
|
|
57
|
+
userAccount: event.data?.[0],
|
|
58
|
+
}
|
|
59
|
+
}),
|
|
60
|
+
setInitialization: assign((context, event) => {
|
|
61
|
+
const { houseAccount, bankList } = event.data
|
|
62
|
+
return {
|
|
63
|
+
houseAccountName: houseAccount.accountName,
|
|
64
|
+
houseAccountNumber: houseAccount.accountNumber,
|
|
65
|
+
houseBankName: houseAccount.bankName,
|
|
66
|
+
bankList: bankList?.data ? bankList.data : bankList,
|
|
67
|
+
}
|
|
68
|
+
}),
|
|
69
|
+
},
|
|
70
|
+
guards: {
|
|
71
|
+
hasUserAccount: (context, event) => {
|
|
72
|
+
return event.data?.[0]
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
services: {
|
|
76
|
+
fetchPaymentInfo: async (context, event) => {
|
|
77
|
+
const { bankInfo } = await request.send(payment.getPaymentInfo())
|
|
78
|
+
const filterArray = bankInfo?.filter((item) => item.bindingType !== 'CRYPTO' && item.bindingType !== 'EWALLET')
|
|
79
|
+
return filterArray || []
|
|
80
|
+
},
|
|
81
|
+
initialize: async (context, event) => {
|
|
82
|
+
const { method } = context
|
|
83
|
+
const [houseAccount, bankList] = await Promise.all([
|
|
84
|
+
request.send(payment.submitDepositTransaction({ method })),
|
|
85
|
+
request.send(payment.getBankList(method)),
|
|
86
|
+
])
|
|
87
|
+
return { houseAccount, bankList }
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
}
|
|
91
|
+
)
|
|
92
|
+
}
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import { assign, createMachine } from 'xstate'
|
|
2
|
+
import padStart from 'lodash/padStart.js'
|
|
3
|
+
import payment from '@jetthai/cuora/src/api/payment.js'
|
|
4
|
+
|
|
5
|
+
export default function (request) {
|
|
6
|
+
const { appSecret } = request.config
|
|
7
|
+
return createMachine(
|
|
8
|
+
{
|
|
9
|
+
id: 'crypto_bank',
|
|
10
|
+
initial: 'loading',
|
|
11
|
+
context: {
|
|
12
|
+
paymentDetails: [],
|
|
13
|
+
|
|
14
|
+
cryptos: [],
|
|
15
|
+
addresses: [],
|
|
16
|
+
cryptoBank: null,
|
|
17
|
+
|
|
18
|
+
amount: null,
|
|
19
|
+
selectedCrypto: null,
|
|
20
|
+
selectedAddress: null,
|
|
21
|
+
selectedBank: null,
|
|
22
|
+
|
|
23
|
+
currentCategory: 'cryptoBank',
|
|
24
|
+
currentPayment: null,
|
|
25
|
+
|
|
26
|
+
calculation: null,
|
|
27
|
+
processing: null,
|
|
28
|
+
result: null,
|
|
29
|
+
|
|
30
|
+
depositTime: null,
|
|
31
|
+
receipt: null,
|
|
32
|
+
proofOptional: false,
|
|
33
|
+
|
|
34
|
+
// use for wallet mode 4
|
|
35
|
+
promotion: null,
|
|
36
|
+
},
|
|
37
|
+
states: {
|
|
38
|
+
loading: {
|
|
39
|
+
initial: 'init1',
|
|
40
|
+
states: {
|
|
41
|
+
init1: {
|
|
42
|
+
invoke: {
|
|
43
|
+
src: 'fetchPayments',
|
|
44
|
+
onDone: {
|
|
45
|
+
target: 'init2',
|
|
46
|
+
actions: 'setPayment',
|
|
47
|
+
},
|
|
48
|
+
onError: {
|
|
49
|
+
target: '#crypto_bank.fail',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
init2: {
|
|
54
|
+
always: [
|
|
55
|
+
{
|
|
56
|
+
target: '#crypto_bank.processing',
|
|
57
|
+
cond: 'isProcessing',
|
|
58
|
+
},
|
|
59
|
+
{ target: '#crypto_bank.loaded' },
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
loaded: {
|
|
65
|
+
always: [{ target: 'debouncing', cond: 'isCalculable' }],
|
|
66
|
+
},
|
|
67
|
+
debouncing: {
|
|
68
|
+
after: {
|
|
69
|
+
1000: {
|
|
70
|
+
target: 'calculating',
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
calculating: {
|
|
75
|
+
invoke: {
|
|
76
|
+
src: 'fetchCalculation',
|
|
77
|
+
onDone: {
|
|
78
|
+
target: 'calculated',
|
|
79
|
+
actions: 'setCalculation',
|
|
80
|
+
},
|
|
81
|
+
onError: {
|
|
82
|
+
target: 'loaded',
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
calculated: {
|
|
87
|
+
on: {
|
|
88
|
+
SUBMIT: [
|
|
89
|
+
{
|
|
90
|
+
target: 'pending',
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
target: 'submitting',
|
|
94
|
+
cond: 'isSubmittable',
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
pending: {
|
|
100
|
+
on: {
|
|
101
|
+
SUBMIT: {
|
|
102
|
+
target: 'submitting',
|
|
103
|
+
cond: 'isSubmittable',
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
submitting: {
|
|
108
|
+
invoke: {
|
|
109
|
+
src: 'submitDeposit',
|
|
110
|
+
onDone: {
|
|
111
|
+
target: 'submitted',
|
|
112
|
+
actions: 'setResult',
|
|
113
|
+
},
|
|
114
|
+
onError: {
|
|
115
|
+
target: 'loaded',
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
processing: {},
|
|
120
|
+
submitted: {},
|
|
121
|
+
fail: {},
|
|
122
|
+
},
|
|
123
|
+
on: {
|
|
124
|
+
SET_CRYPTO: {
|
|
125
|
+
target: '.loaded',
|
|
126
|
+
actions: 'setCrypto',
|
|
127
|
+
},
|
|
128
|
+
SET_ADDRESS: {
|
|
129
|
+
target: '.loaded',
|
|
130
|
+
actions: 'setAddress',
|
|
131
|
+
},
|
|
132
|
+
SET_AMOUNT: {
|
|
133
|
+
target: '.loaded',
|
|
134
|
+
actions: ['setAmount', 'clearCalculation'],
|
|
135
|
+
},
|
|
136
|
+
SET_PROOF_OPTIONAL: {
|
|
137
|
+
actions: 'setProofOptional',
|
|
138
|
+
},
|
|
139
|
+
CALCULATE: {
|
|
140
|
+
target: '.debouncing',
|
|
141
|
+
actions: 'clearCalculation',
|
|
142
|
+
},
|
|
143
|
+
SET_DEPOSIT_TIME: {
|
|
144
|
+
actions: 'setDepositTime',
|
|
145
|
+
},
|
|
146
|
+
SET_RECEIPT: {
|
|
147
|
+
actions: 'setReceipt',
|
|
148
|
+
},
|
|
149
|
+
SET_PROMOTION: {
|
|
150
|
+
actions: 'setPromotion',
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
actions: {
|
|
156
|
+
setPayment: assign((context, event) => {
|
|
157
|
+
const cryptoBank = event.data.find((element) => element.category === context.currentCategory)
|
|
158
|
+
cryptoBank.banks = (cryptoBank.banks || []).map((crypto) => ({
|
|
159
|
+
...crypto,
|
|
160
|
+
label: crypto.cryptoName,
|
|
161
|
+
value: cryptoBank.method,
|
|
162
|
+
icon: crypto.symbol,
|
|
163
|
+
}))
|
|
164
|
+
const defaultCrypto = []
|
|
165
|
+
cryptoBank.banks?.forEach((bank) => {
|
|
166
|
+
var existingCryptoName = defaultCrypto.find((item) => {
|
|
167
|
+
return item.cryptoName === bank.cryptoName
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
if (!existingCryptoName) {
|
|
171
|
+
defaultCrypto.push(bank)
|
|
172
|
+
}
|
|
173
|
+
})
|
|
174
|
+
const currentPayment = {
|
|
175
|
+
label: defaultCrypto[0]?.network,
|
|
176
|
+
value: defaultCrypto[0]?.network,
|
|
177
|
+
icon: defaultCrypto[0]?.network,
|
|
178
|
+
}
|
|
179
|
+
const defaultAddresses = (cryptoBank.banks || [])
|
|
180
|
+
.filter((element) => element.cryptoName === defaultCrypto[0].cryptoName)
|
|
181
|
+
.map((value, i) => {
|
|
182
|
+
return {
|
|
183
|
+
label: value.address,
|
|
184
|
+
value: value.address,
|
|
185
|
+
icon: null,
|
|
186
|
+
}
|
|
187
|
+
})
|
|
188
|
+
|
|
189
|
+
return {
|
|
190
|
+
cryptos: defaultCrypto,
|
|
191
|
+
addresses: defaultAddresses,
|
|
192
|
+
cryptoBank,
|
|
193
|
+
selectedCrypto: defaultCrypto[0],
|
|
194
|
+
selectedAddress: defaultAddresses[0],
|
|
195
|
+
options: defaultCrypto[0]?.optional,
|
|
196
|
+
currentPayment,
|
|
197
|
+
processing: cryptoBank.processing?.[0],
|
|
198
|
+
}
|
|
199
|
+
}),
|
|
200
|
+
setCrypto: assign((context, event) => {
|
|
201
|
+
const { cryptoBank } = context
|
|
202
|
+
const selectedCrypto = cryptoBank.banks.find((bank) => bank.label === event.data.label)
|
|
203
|
+
const addresses = cryptoBank.banks
|
|
204
|
+
.filter((element) => element.cryptoName === selectedCrypto.cryptoName)
|
|
205
|
+
.map((value, i) => {
|
|
206
|
+
return {
|
|
207
|
+
label: value.address,
|
|
208
|
+
value: value.address,
|
|
209
|
+
icon: null,
|
|
210
|
+
}
|
|
211
|
+
})
|
|
212
|
+
return {
|
|
213
|
+
addresses,
|
|
214
|
+
selectedCrypto: selectedCrypto,
|
|
215
|
+
selectedAddress: addresses[0],
|
|
216
|
+
selectedAmount: null,
|
|
217
|
+
calculation: null,
|
|
218
|
+
options: cryptoBank.optional,
|
|
219
|
+
}
|
|
220
|
+
}),
|
|
221
|
+
setAddress: assign((context, event) => {
|
|
222
|
+
const { cryptoBank, selectedCrypto } = context
|
|
223
|
+
const selectedCryptoByAddress = cryptoBank.banks.find((bank) => bank.label === selectedCrypto.label && bank.address === event.data.value)
|
|
224
|
+
return {
|
|
225
|
+
selectedCrypto: selectedCryptoByAddress,
|
|
226
|
+
selectedAddress: event.data,
|
|
227
|
+
}
|
|
228
|
+
}),
|
|
229
|
+
setAmount: assign((context, event) => {
|
|
230
|
+
return {
|
|
231
|
+
amount: event.data,
|
|
232
|
+
}
|
|
233
|
+
}),
|
|
234
|
+
setCalculation: assign((context, event) => {
|
|
235
|
+
// V2接口轉換中回傳的資料結構不同
|
|
236
|
+
const { data } = event.data
|
|
237
|
+
if (data) {
|
|
238
|
+
return {
|
|
239
|
+
calculation: data,
|
|
240
|
+
}
|
|
241
|
+
} else {
|
|
242
|
+
return {
|
|
243
|
+
calculation: event.data,
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}),
|
|
247
|
+
clearCalculation: assign((context, event) => {
|
|
248
|
+
return {
|
|
249
|
+
calculation: null,
|
|
250
|
+
}
|
|
251
|
+
}),
|
|
252
|
+
setResult: assign((context, event) => {
|
|
253
|
+
return {
|
|
254
|
+
result: event.data,
|
|
255
|
+
}
|
|
256
|
+
}),
|
|
257
|
+
setProofOptional: assign((context, event) => {
|
|
258
|
+
return {
|
|
259
|
+
proofOptional: event.data,
|
|
260
|
+
}
|
|
261
|
+
}),
|
|
262
|
+
setDepositTime: assign((context, event) => {
|
|
263
|
+
return {
|
|
264
|
+
depositTime: event.data,
|
|
265
|
+
}
|
|
266
|
+
}),
|
|
267
|
+
setReceipt: assign((context, event) => {
|
|
268
|
+
return {
|
|
269
|
+
receipt: event.data,
|
|
270
|
+
}
|
|
271
|
+
}),
|
|
272
|
+
setPromotion: assign((context, event) => {
|
|
273
|
+
const promotion = event.data
|
|
274
|
+
return {
|
|
275
|
+
promotion,
|
|
276
|
+
}
|
|
277
|
+
}),
|
|
278
|
+
},
|
|
279
|
+
guards: {
|
|
280
|
+
isCalculable: (context, event) => {
|
|
281
|
+
const { selectedCrypto, selectedAddress, cryptoBank, amount } = context
|
|
282
|
+
return selectedCrypto && selectedAddress && amount && cryptoBank.minimum <= +amount && +amount <= cryptoBank.maximum
|
|
283
|
+
},
|
|
284
|
+
isSubmittable: (context, event) => {
|
|
285
|
+
const { selectedCrypto, selectedAddress, amount, depositTime, receipt, proofOptional } = context
|
|
286
|
+
return selectedCrypto && selectedAddress && amount && depositTime && (receipt || proofOptional)
|
|
287
|
+
},
|
|
288
|
+
isProcessing: (context, event) => {
|
|
289
|
+
return context.processing
|
|
290
|
+
},
|
|
291
|
+
},
|
|
292
|
+
services: {
|
|
293
|
+
fetchPayments: async (context, event) => {
|
|
294
|
+
return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
|
|
295
|
+
},
|
|
296
|
+
fetchCalculation: async (context, event) => {
|
|
297
|
+
const { selectedCrypto, amount, promotion } = context
|
|
298
|
+
return await request.send(
|
|
299
|
+
payment.getCryptoDepositExpectedResult({
|
|
300
|
+
method: selectedCrypto.value,
|
|
301
|
+
amount,
|
|
302
|
+
cryptoCurrency: selectedCrypto.symbol,
|
|
303
|
+
promotionsNo: promotion?.activityNo,
|
|
304
|
+
})
|
|
305
|
+
)
|
|
306
|
+
},
|
|
307
|
+
submitDeposit: async (context, event) => {
|
|
308
|
+
const { selectedCrypto, depositTime, receipt, amount, promotion } = context
|
|
309
|
+
return await request.send(
|
|
310
|
+
payment.submitDepositTransactionCryptoBank({
|
|
311
|
+
method: selectedCrypto.value,
|
|
312
|
+
amount: amount,
|
|
313
|
+
cryptoCurrency: selectedCrypto.symbol,
|
|
314
|
+
cryptoNetwork: selectedCrypto.network,
|
|
315
|
+
sourceAddress: selectedCrypto.address,
|
|
316
|
+
promotionsNo: promotion?.activityNo,
|
|
317
|
+
depositTime,
|
|
318
|
+
receipt,
|
|
319
|
+
})
|
|
320
|
+
)
|
|
321
|
+
},
|
|
322
|
+
},
|
|
323
|
+
}
|
|
324
|
+
)
|
|
325
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { assign, createMachine } from 'xstate'
|
|
2
2
|
import payment from '@jetthai/cuora/src/api/payment.js'
|
|
3
|
+
import { max } from '../../util/index.js'
|
|
3
4
|
|
|
4
5
|
export default function (request, context) {
|
|
5
6
|
const { paymentDetail = [], promotion, selectedAmount, siteConfig } = context || {}
|
|
@@ -81,15 +82,10 @@ export default function (request, context) {
|
|
|
81
82
|
actions: 'setResult',
|
|
82
83
|
},
|
|
83
84
|
onError: {
|
|
84
|
-
target: '
|
|
85
|
+
target: 'calculated',
|
|
85
86
|
},
|
|
86
87
|
},
|
|
87
88
|
},
|
|
88
|
-
fail: {
|
|
89
|
-
after: {
|
|
90
|
-
0: { target: 'calculated' },
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
89
|
submitted: {},
|
|
94
90
|
},
|
|
95
91
|
on: {
|
|
@@ -97,7 +93,6 @@ export default function (request, context) {
|
|
|
97
93
|
target: '.debouncing',
|
|
98
94
|
actions: 'setPromotion',
|
|
99
95
|
internal: false,
|
|
100
|
-
cond: 'isPromotionChanged',
|
|
101
96
|
},
|
|
102
97
|
SET_CRYPTO: {
|
|
103
98
|
target: '.debouncing',
|
|
@@ -182,6 +177,7 @@ export default function (request, context) {
|
|
|
182
177
|
addresses,
|
|
183
178
|
selectedCrypto: selectedCrypto,
|
|
184
179
|
selectedAddress: addresses[0],
|
|
180
|
+
selectedAmount: null,
|
|
185
181
|
calculation: null,
|
|
186
182
|
options: cryptoBank.optional,
|
|
187
183
|
}
|
|
@@ -229,9 +225,11 @@ export default function (request, context) {
|
|
|
229
225
|
}
|
|
230
226
|
}),
|
|
231
227
|
setPromotion: assign((context, event) => {
|
|
228
|
+
const { cryptoBank, selectedAmount } = context
|
|
232
229
|
const promotion = event.data
|
|
233
230
|
return {
|
|
234
231
|
promotion,
|
|
232
|
+
selectedAmount: max(promotion.minimumAmount, cryptoBank.minimum, selectedAmount, 0),
|
|
235
233
|
calculation: null,
|
|
236
234
|
}
|
|
237
235
|
}),
|
|
@@ -247,18 +245,9 @@ export default function (request, context) {
|
|
|
247
245
|
}),
|
|
248
246
|
},
|
|
249
247
|
guards: {
|
|
250
|
-
isPromotionChanged: (context, event) => {
|
|
251
|
-
return event.data?.promotionsNo !== context.promotion?.promotionsNo
|
|
252
|
-
},
|
|
253
248
|
isCalculable: (context, event) => {
|
|
254
|
-
const { selectedCrypto, selectedAddress, selectedAmount } = context
|
|
255
|
-
return
|
|
256
|
-
selectedCrypto &&
|
|
257
|
-
selectedAddress &&
|
|
258
|
-
selectedAmount &&
|
|
259
|
-
selectedCrypto.minimum <= +selectedAmount &&
|
|
260
|
-
+selectedAmount <= selectedCrypto.maximum
|
|
261
|
-
)
|
|
249
|
+
const { selectedCrypto, selectedAddress, cryptoBank, selectedAmount } = context
|
|
250
|
+
return selectedCrypto && selectedAddress && selectedAmount && cryptoBank.minimum <= +selectedAmount && +selectedAmount <= cryptoBank.maximum
|
|
262
251
|
},
|
|
263
252
|
isSubmittable: (context, event) => {
|
|
264
253
|
const { selectedCrypto, selectedAddress, selectedAmount, depositTime, receipt, calculation, siteConfig } = context
|
|
@@ -292,7 +281,7 @@ export default function (request, context) {
|
|
|
292
281
|
method: selectedCrypto.value,
|
|
293
282
|
amount: selectedAmount,
|
|
294
283
|
cryptoCurrency: selectedCrypto.symbol,
|
|
295
|
-
cryptoNetwork: selectedCrypto.
|
|
284
|
+
cryptoNetwork: selectedCrypto.network,
|
|
296
285
|
sourceAddress: selectedCrypto.address,
|
|
297
286
|
promotionsNo: promotion?.promotionsNo,
|
|
298
287
|
depositTime,
|