@jetthai/cuora 1.1.263 → 1.1.264
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.264](https://github.com/jetthai/cuora-module/compare/v1.1.263...v1.1.264) (2024-05-11)
|
|
6
|
+
|
|
5
7
|
### [1.1.263](https://github.com/jetthai/cuora-module/compare/v1.1.262...v1.1.263) (2024-05-10)
|
|
6
8
|
|
|
7
9
|
### [1.1.262](https://github.com/jetthai/cuora-module/compare/v1.1.261...v1.1.262) (2024-05-10)
|
package/package.json
CHANGED
|
@@ -11,9 +11,7 @@ export default function (request) {
|
|
|
11
11
|
currentCategory: 'cryptoQrcode',
|
|
12
12
|
currentPayment: null,
|
|
13
13
|
cryptos: [],
|
|
14
|
-
networks: [],
|
|
15
14
|
selectedCrypto: null,
|
|
16
|
-
selectedNetwork: null,
|
|
17
15
|
|
|
18
16
|
resultMap: {},
|
|
19
17
|
result: {
|
|
@@ -71,61 +69,38 @@ export default function (request) {
|
|
|
71
69
|
target: '.finding',
|
|
72
70
|
actions: 'setCrypto',
|
|
73
71
|
},
|
|
74
|
-
SET_NETWORK: {
|
|
75
|
-
target: '.finding',
|
|
76
|
-
actions: 'setNetwork',
|
|
77
|
-
},
|
|
78
72
|
},
|
|
79
73
|
},
|
|
80
74
|
{
|
|
81
75
|
actions: {
|
|
82
76
|
setInitData: assign((context, event) => {
|
|
83
77
|
const paymentDetail = event.data || []
|
|
84
|
-
const
|
|
85
|
-
const
|
|
86
|
-
const cryptos = payments.map((payment) => ({ ...payment, label: payment.channel, value: payment.method, icon: payment.channel }))
|
|
87
|
-
const networks = currentPayment?.networkName.map((value, i) => {
|
|
78
|
+
const currentPayment = paymentDetail.find((item) => item.transferType === 'deposit' && item.category === context.currentCategory)
|
|
79
|
+
const cryptos = currentPayment?.cryptoOptional?.map((value, i) => {
|
|
88
80
|
return {
|
|
89
|
-
|
|
90
|
-
value,
|
|
91
|
-
|
|
81
|
+
...currentPayment,
|
|
82
|
+
label: value,
|
|
83
|
+
network: currentPayment?.networkName[i],
|
|
84
|
+
icon: currentPayment.channel,
|
|
92
85
|
}
|
|
93
86
|
})
|
|
94
|
-
|
|
95
87
|
return {
|
|
96
88
|
cryptos,
|
|
97
|
-
networks,
|
|
98
89
|
selectedCrypto: cryptos[0],
|
|
99
|
-
selectedNetwork: networks[0],
|
|
100
90
|
currentPayment,
|
|
101
91
|
}
|
|
102
92
|
}),
|
|
103
93
|
setCrypto: assign((context, event) => {
|
|
104
94
|
const { cryptos } = context
|
|
105
|
-
const selectedCrypto = cryptos.find((crypto) => crypto.
|
|
106
|
-
|
|
107
|
-
selectedCrypto?.networkName.map((value, i) => {
|
|
108
|
-
return {
|
|
109
|
-
label: selectedCrypto?.networkOptional?.[i],
|
|
110
|
-
value,
|
|
111
|
-
icon: value,
|
|
112
|
-
}
|
|
113
|
-
}) || []
|
|
114
|
-
return {
|
|
115
|
-
networks,
|
|
116
|
-
selectedCrypto,
|
|
117
|
-
selectedNetwork: networks[0],
|
|
118
|
-
}
|
|
119
|
-
}),
|
|
120
|
-
setNetwork: assign((context, event) => {
|
|
121
|
-
return { selectedNetwork: event.data }
|
|
95
|
+
const selectedCrypto = cryptos.find((crypto) => crypto.label === event.data.label)
|
|
96
|
+
return { selectedCrypto }
|
|
122
97
|
}),
|
|
123
98
|
setResultFromLocal: assign((context, event) => {
|
|
124
|
-
const { resultMap,
|
|
125
|
-
return { result: resultMap[
|
|
99
|
+
const { resultMap, selectedCrypto } = context
|
|
100
|
+
return { result: resultMap[selectedCrypto.network] }
|
|
126
101
|
}),
|
|
127
102
|
setResult: assign((context, event) => {
|
|
128
|
-
const { resultMap,
|
|
103
|
+
const { resultMap, selectedCrypto } = context
|
|
129
104
|
const { action, cdtime, accountNumber, currency, network, name, qrcode } = event.data
|
|
130
105
|
const result = {
|
|
131
106
|
action,
|
|
@@ -141,15 +116,15 @@ export default function (request) {
|
|
|
141
116
|
result,
|
|
142
117
|
resultMap: {
|
|
143
118
|
...resultMap,
|
|
144
|
-
[
|
|
119
|
+
[selectedCrypto.network]: result,
|
|
145
120
|
},
|
|
146
121
|
}
|
|
147
122
|
}),
|
|
148
123
|
},
|
|
149
124
|
guards: {
|
|
150
125
|
isFound: (context, event) => {
|
|
151
|
-
const { resultMap,
|
|
152
|
-
return resultMap[
|
|
126
|
+
const { resultMap, selectedCrypto } = context
|
|
127
|
+
return resultMap[selectedCrypto.network]
|
|
153
128
|
},
|
|
154
129
|
},
|
|
155
130
|
services: {
|
|
@@ -157,12 +132,12 @@ export default function (request) {
|
|
|
157
132
|
return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
|
|
158
133
|
},
|
|
159
134
|
submitDeposit: async (context, event) => {
|
|
160
|
-
const { currentPayment,
|
|
135
|
+
const { currentPayment, selectedCrypto } = context
|
|
161
136
|
return await request.send(
|
|
162
137
|
payment.submitDepositTransactionCrypto({
|
|
163
138
|
method: currentPayment.method,
|
|
164
139
|
cryptoCurrency: currentPayment.channel,
|
|
165
|
-
cryptoNetwork:
|
|
140
|
+
cryptoNetwork: selectedCrypto.network,
|
|
166
141
|
})
|
|
167
142
|
)
|
|
168
143
|
},
|
|
@@ -13,12 +13,10 @@ export default function (request) {
|
|
|
13
13
|
paymentDetails: [],
|
|
14
14
|
|
|
15
15
|
cryptos: [],
|
|
16
|
-
networks: [],
|
|
17
16
|
sourceAddress: '',
|
|
18
17
|
|
|
19
18
|
amount: null,
|
|
20
19
|
selectedCrypto: null,
|
|
21
|
-
selectedNetwork: null,
|
|
22
20
|
|
|
23
21
|
currentCategory: 'cryptoWay',
|
|
24
22
|
currentPayment: null,
|
|
@@ -105,10 +103,6 @@ export default function (request) {
|
|
|
105
103
|
target: '.loaded',
|
|
106
104
|
actions: 'setCrypto',
|
|
107
105
|
},
|
|
108
|
-
SET_NETWORK: {
|
|
109
|
-
target: '.loaded',
|
|
110
|
-
actions: 'setNetwork',
|
|
111
|
-
},
|
|
112
106
|
SET_ADDRESS: {
|
|
113
107
|
actions: 'setAddress',
|
|
114
108
|
},
|
|
@@ -128,54 +122,29 @@ export default function (request) {
|
|
|
128
122
|
{
|
|
129
123
|
actions: {
|
|
130
124
|
setPayment: assign((context, event) => {
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
value,
|
|
141
|
-
icon: value,
|
|
142
|
-
}
|
|
143
|
-
}) || []
|
|
125
|
+
const currentPayment = event.data.find((item) => item.category === context.currentCategory)
|
|
126
|
+
const cryptos = currentPayment?.cryptoOptional?.map((value, i) => {
|
|
127
|
+
return {
|
|
128
|
+
...currentPayment,
|
|
129
|
+
label: value,
|
|
130
|
+
network: currentPayment?.networkName[i],
|
|
131
|
+
icon: currentPayment.channel,
|
|
132
|
+
}
|
|
133
|
+
})
|
|
144
134
|
return {
|
|
145
135
|
cryptos,
|
|
146
|
-
networks: defaultNetworks,
|
|
147
136
|
selectedCrypto: cryptos[0],
|
|
148
|
-
selectedNetwork: defaultNetworks[0],
|
|
149
137
|
currentPayment,
|
|
150
138
|
}
|
|
151
139
|
}),
|
|
152
140
|
setCrypto: assign((context, event) => {
|
|
153
|
-
const { cryptos
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
value,
|
|
160
|
-
icon: value,
|
|
161
|
-
}
|
|
162
|
-
}) || []
|
|
163
|
-
|
|
164
|
-
const properties = {
|
|
165
|
-
selectedCrypto: event.data,
|
|
166
|
-
networks,
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
if (!networks.includes(selectedNetwork)) {
|
|
170
|
-
properties.selectedNetwork = null
|
|
171
|
-
properties.amount = null
|
|
172
|
-
properties.calculation = null
|
|
141
|
+
const { cryptos } = context
|
|
142
|
+
const selectedCrypto = cryptos.find((crypto) => crypto.label === event.data.label)
|
|
143
|
+
return {
|
|
144
|
+
selectedCrypto: selectedCrypto,
|
|
145
|
+
amount: null,
|
|
146
|
+
calculation: null,
|
|
173
147
|
}
|
|
174
|
-
|
|
175
|
-
return properties
|
|
176
|
-
}),
|
|
177
|
-
setNetwork: assign((context, event) => {
|
|
178
|
-
return { selectedNetwork: event.data }
|
|
179
148
|
}),
|
|
180
149
|
setAmount: assign((context, event) => {
|
|
181
150
|
return {
|
|
@@ -213,15 +182,14 @@ export default function (request) {
|
|
|
213
182
|
isCalculable: (context, event) => {
|
|
214
183
|
const {
|
|
215
184
|
selectedCrypto,
|
|
216
|
-
selectedNetwork,
|
|
217
185
|
amount,
|
|
218
186
|
currentPayment: { maximum, minimum },
|
|
219
187
|
} = context
|
|
220
|
-
return selectedCrypto &&
|
|
188
|
+
return selectedCrypto && amount && minimum <= +amount && +amount <= maximum
|
|
221
189
|
},
|
|
222
190
|
isSubmittable: (context, event) => {
|
|
223
|
-
const { selectedCrypto,
|
|
224
|
-
return selectedCrypto &&
|
|
191
|
+
const { selectedCrypto, amount } = context
|
|
192
|
+
return selectedCrypto && amount
|
|
225
193
|
},
|
|
226
194
|
},
|
|
227
195
|
services: {
|
|
@@ -240,13 +208,13 @@ export default function (request) {
|
|
|
240
208
|
)
|
|
241
209
|
},
|
|
242
210
|
submitDeposit: async (context, event) => {
|
|
243
|
-
const { selectedCrypto,
|
|
211
|
+
const { selectedCrypto, amount } = context
|
|
244
212
|
return await request.send(
|
|
245
213
|
payment.submitDepositTransactionCrypto({
|
|
246
214
|
method: selectedCrypto.method,
|
|
247
215
|
amount: amount,
|
|
248
216
|
cryptoCurrency: selectedCrypto.channel,
|
|
249
|
-
cryptoNetwork:
|
|
217
|
+
cryptoNetwork: selectedCrypto.network,
|
|
250
218
|
})
|
|
251
219
|
)
|
|
252
220
|
},
|