@jetthai/cuora 1.1.175 → 1.1.176
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,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.176](https://github.com/jetthai/cuora-module/compare/v1.1.175...v1.1.176) (2023-09-19)
|
|
6
|
+
|
|
5
7
|
### [1.1.175](https://github.com/jetthai/cuora-module/compare/v1.1.174...v1.1.175) (2023-09-18)
|
|
6
8
|
|
|
7
9
|
### [1.1.174](https://github.com/jetthai/cuora-module/compare/v1.1.173...v1.1.174) (2023-09-08)
|
package/package.json
CHANGED
|
@@ -0,0 +1,154 @@
|
|
|
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
|
+
currentCategory: 'cryptoQrcode',
|
|
11
|
+
currentPayment: null,
|
|
12
|
+
cryptos: [],
|
|
13
|
+
networks: [],
|
|
14
|
+
selectedCrypto: null,
|
|
15
|
+
selectedNetwork: null,
|
|
16
|
+
resultMap: {},
|
|
17
|
+
result: {},
|
|
18
|
+
},
|
|
19
|
+
states: {
|
|
20
|
+
loading: {
|
|
21
|
+
invoke: {
|
|
22
|
+
src: 'fetchPaymentDetail',
|
|
23
|
+
onDone: {
|
|
24
|
+
target: 'submitting',
|
|
25
|
+
actions: 'setInitData',
|
|
26
|
+
},
|
|
27
|
+
onError: {
|
|
28
|
+
target: 'fail',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
finding: {
|
|
33
|
+
always: [
|
|
34
|
+
{
|
|
35
|
+
target: 'idle',
|
|
36
|
+
actions: 'setResultFromLocal',
|
|
37
|
+
cond: 'isFound',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
target: 'submitting',
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
submitting: {
|
|
45
|
+
invoke: {
|
|
46
|
+
src: 'submitDeposit',
|
|
47
|
+
onDone: {
|
|
48
|
+
target: 'idle',
|
|
49
|
+
actions: 'setResult',
|
|
50
|
+
},
|
|
51
|
+
onError: {
|
|
52
|
+
target: 'idle',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
idle: {},
|
|
57
|
+
fail: {},
|
|
58
|
+
},
|
|
59
|
+
on: {
|
|
60
|
+
SET_CRYPTO: {
|
|
61
|
+
target: '.finding',
|
|
62
|
+
actions: 'setCrypto',
|
|
63
|
+
},
|
|
64
|
+
SET_NETWORK: {
|
|
65
|
+
target: '.finding',
|
|
66
|
+
actions: 'setNetwork',
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
actions: {
|
|
72
|
+
setInitData: assign((context, event) => {
|
|
73
|
+
const paymentDetail = event.data || []
|
|
74
|
+
const payments = paymentDetail.filter((item) => item.category === context.currentCategory)
|
|
75
|
+
const currentPayment = payments[0]
|
|
76
|
+
const cryptos = payments.map((payment) => ({ ...payment, label: payment.channel, value: payment.method, icon: payment.channel }))
|
|
77
|
+
const networks = currentPayment?.networkName.map((value, i) => {
|
|
78
|
+
return {
|
|
79
|
+
label: currentPayment.networkOptional?.[i],
|
|
80
|
+
value,
|
|
81
|
+
icon: value,
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
cryptos,
|
|
87
|
+
networks,
|
|
88
|
+
selectedCrypto: cryptos[0],
|
|
89
|
+
selectedNetwork: networks[0],
|
|
90
|
+
currentPayment,
|
|
91
|
+
}
|
|
92
|
+
}),
|
|
93
|
+
setCrypto: assign((context, event) => {
|
|
94
|
+
const { cryptos } = context
|
|
95
|
+
const selectedCrypto = cryptos.find((crypto) => crypto.channel === event.data.channel)
|
|
96
|
+
const networks =
|
|
97
|
+
selectedCrypto?.networkName.map((value, i) => {
|
|
98
|
+
return {
|
|
99
|
+
label: selectedCrypto?.networkOptional?.[i],
|
|
100
|
+
value,
|
|
101
|
+
icon: value,
|
|
102
|
+
}
|
|
103
|
+
}) || []
|
|
104
|
+
return {
|
|
105
|
+
networks,
|
|
106
|
+
selectedCrypto,
|
|
107
|
+
selectedNetwork: networks[0],
|
|
108
|
+
}
|
|
109
|
+
}),
|
|
110
|
+
setNetwork: assign((context, event) => {
|
|
111
|
+
return { selectedNetwork: event.data }
|
|
112
|
+
}),
|
|
113
|
+
setResultFromLocal: assign((context, event) => {
|
|
114
|
+
const { resultMap, selectedCrypto, selectedNetwork } = context
|
|
115
|
+
return { result: resultMap[`${selectedCrypto.value}_${selectedNetwork.value}`] }
|
|
116
|
+
}),
|
|
117
|
+
setResult: assign((context, event) => {
|
|
118
|
+
const { resultMap, selectedCrypto, selectedNetwork } = context
|
|
119
|
+
const { accountNumber, currency, network, qrcode, forexRate } = event.data
|
|
120
|
+
const result = { accountNumber, currency, network, qrcode, forexRate }
|
|
121
|
+
|
|
122
|
+
return {
|
|
123
|
+
result,
|
|
124
|
+
resultMap: {
|
|
125
|
+
...resultMap,
|
|
126
|
+
[`${selectedCrypto.value}_${selectedNetwork.value}`]: result,
|
|
127
|
+
},
|
|
128
|
+
}
|
|
129
|
+
}),
|
|
130
|
+
},
|
|
131
|
+
guards: {
|
|
132
|
+
isFound: (context, event) => {
|
|
133
|
+
const { resultMap, selectedCrypto, selectedNetwork } = context
|
|
134
|
+
return resultMap[`${selectedCrypto.value}_${selectedNetwork.value}`]
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
services: {
|
|
138
|
+
fetchPaymentDetail: async (context, event) => {
|
|
139
|
+
return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
|
|
140
|
+
},
|
|
141
|
+
submitDeposit: async (context, event) => {
|
|
142
|
+
const { currentPayment, selectedNetwork } = context
|
|
143
|
+
return await request.send(
|
|
144
|
+
payment.submitDepositTransactionCrypto({
|
|
145
|
+
method: currentPayment.method,
|
|
146
|
+
cryptoCurrency: currentPayment.channel,
|
|
147
|
+
cryptoNetwork: selectedNetwork.value,
|
|
148
|
+
})
|
|
149
|
+
)
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
}
|
|
153
|
+
)
|
|
154
|
+
}
|
|
@@ -4,6 +4,8 @@ import qrcode_v2 from './qrcode_v2.js'
|
|
|
4
4
|
import deposit_fc from './deposit_fc.js'
|
|
5
5
|
import crypto from './crypto.js'
|
|
6
6
|
import crypto_button from './crypto_button.js'
|
|
7
|
+
import crypto_qrcode from './crypto_qrcode.js'
|
|
8
|
+
import crypto_way_cash from './crypto_way_cash.js'
|
|
7
9
|
import direct from './direct.js'
|
|
8
10
|
import amb from './amb.js'
|
|
9
11
|
import float from './float.js'
|
|
@@ -15,7 +17,6 @@ import usdt_cash from './usdt_cash.js'
|
|
|
15
17
|
import crypto_cash from './crypto_cash.js'
|
|
16
18
|
import direct_cash from './direct_cash.js'
|
|
17
19
|
import loadcard_cash from './loadcard_cash.js'
|
|
18
|
-
import crypto_way_cash from './crypto_way_cash.js'
|
|
19
20
|
|
|
20
21
|
export default {
|
|
21
22
|
manual_vn,
|
|
@@ -24,6 +25,8 @@ export default {
|
|
|
24
25
|
deposit_fc,
|
|
25
26
|
crypto,
|
|
26
27
|
crypto_button,
|
|
28
|
+
crypto_qrcode,
|
|
29
|
+
crypto_way_cash,
|
|
27
30
|
direct,
|
|
28
31
|
amb,
|
|
29
32
|
float,
|
|
@@ -35,5 +38,4 @@ export default {
|
|
|
35
38
|
crypto_cash,
|
|
36
39
|
direct_cash,
|
|
37
40
|
loadcard_cash,
|
|
38
|
-
crypto_way_cash,
|
|
39
41
|
}
|