@jetthai/cuora 1.1.262 → 1.1.263
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.263](https://github.com/jetthai/cuora-module/compare/v1.1.262...v1.1.263) (2024-05-10)
|
|
6
|
+
|
|
5
7
|
### [1.1.262](https://github.com/jetthai/cuora-module/compare/v1.1.261...v1.1.262) (2024-05-10)
|
|
6
8
|
|
|
7
9
|
### [1.1.261](https://github.com/jetthai/cuora-module/compare/v1.1.260...v1.1.261) (2024-05-09)
|
package/package.json
CHANGED
|
@@ -10,9 +10,7 @@ export default function (request) {
|
|
|
10
10
|
currentCategory: 'cryptoQrcode',
|
|
11
11
|
currentPayment: null,
|
|
12
12
|
cryptos: [],
|
|
13
|
-
networks: [],
|
|
14
13
|
selectedCrypto: null,
|
|
15
|
-
selectedNetwork: null,
|
|
16
14
|
resultMap: {},
|
|
17
15
|
result: {},
|
|
18
16
|
},
|
|
@@ -71,51 +69,33 @@ export default function (request) {
|
|
|
71
69
|
actions: {
|
|
72
70
|
setInitData: assign((context, event) => {
|
|
73
71
|
const paymentDetail = event.data || []
|
|
74
|
-
const
|
|
75
|
-
const
|
|
76
|
-
const cryptos = payments.map((payment) => ({ ...payment, label: payment.channel, value: payment.method, icon: payment.channel }))
|
|
77
|
-
const networks = currentPayment?.networkName.map((value, i) => {
|
|
72
|
+
const currentPayment = paymentDetail.find((item) => item.category === context.currentCategory)
|
|
73
|
+
const cryptos = currentPayment?.cryptoOptional?.map((value, i) => {
|
|
78
74
|
return {
|
|
79
|
-
|
|
80
|
-
value,
|
|
81
|
-
|
|
75
|
+
...currentPayment,
|
|
76
|
+
label: value,
|
|
77
|
+
network: currentPayment?.networkName[i],
|
|
78
|
+
icon: currentPayment.channel,
|
|
82
79
|
}
|
|
83
80
|
})
|
|
84
81
|
|
|
85
82
|
return {
|
|
86
83
|
cryptos,
|
|
87
|
-
networks,
|
|
88
84
|
selectedCrypto: cryptos[0],
|
|
89
|
-
selectedNetwork: networks[0],
|
|
90
85
|
currentPayment,
|
|
91
86
|
}
|
|
92
87
|
}),
|
|
93
88
|
setCrypto: assign((context, event) => {
|
|
94
89
|
const { cryptos } = context
|
|
95
|
-
const selectedCrypto = cryptos.find((crypto) => crypto.
|
|
96
|
-
|
|
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 }
|
|
90
|
+
const selectedCrypto = cryptos.find((crypto) => crypto.label === event.data.label)
|
|
91
|
+
return { selectedCrypto }
|
|
112
92
|
}),
|
|
113
93
|
setResultFromLocal: assign((context, event) => {
|
|
114
|
-
const { resultMap, selectedCrypto
|
|
115
|
-
return { result: resultMap[`${selectedCrypto.
|
|
94
|
+
const { resultMap, selectedCrypto } = context
|
|
95
|
+
return { result: resultMap[`${selectedCrypto.channel}_${selectedCrypto.network}`] }
|
|
116
96
|
}),
|
|
117
97
|
setResult: assign((context, event) => {
|
|
118
|
-
const { resultMap, selectedCrypto
|
|
98
|
+
const { resultMap, selectedCrypto } = context
|
|
119
99
|
const { accountNumber, currency, network, qrcode, forexRate } = event.data
|
|
120
100
|
const result = { accountNumber, currency, network, qrcode, forexRate }
|
|
121
101
|
|
|
@@ -123,15 +103,15 @@ export default function (request) {
|
|
|
123
103
|
result,
|
|
124
104
|
resultMap: {
|
|
125
105
|
...resultMap,
|
|
126
|
-
[`${selectedCrypto.
|
|
106
|
+
[`${selectedCrypto.channel}_${selectedCrypto.network}`]: result,
|
|
127
107
|
},
|
|
128
108
|
}
|
|
129
109
|
}),
|
|
130
110
|
},
|
|
131
111
|
guards: {
|
|
132
112
|
isFound: (context, event) => {
|
|
133
|
-
const { resultMap, selectedCrypto
|
|
134
|
-
return resultMap[`${selectedCrypto.
|
|
113
|
+
const { resultMap, selectedCrypto } = context
|
|
114
|
+
return resultMap[`${selectedCrypto.channel}_${selectedCrypto.network}`]
|
|
135
115
|
},
|
|
136
116
|
},
|
|
137
117
|
services: {
|
|
@@ -139,12 +119,12 @@ export default function (request) {
|
|
|
139
119
|
return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
|
|
140
120
|
},
|
|
141
121
|
submitDeposit: async (context, event) => {
|
|
142
|
-
const {
|
|
122
|
+
const { selectedCrypto } = context
|
|
143
123
|
return await request.send(
|
|
144
124
|
payment.submitDepositTransactionCrypto({
|
|
145
|
-
method:
|
|
146
|
-
cryptoCurrency:
|
|
147
|
-
cryptoNetwork:
|
|
125
|
+
method: selectedCrypto.method,
|
|
126
|
+
cryptoCurrency: selectedCrypto.channel,
|
|
127
|
+
cryptoNetwork: selectedCrypto.network,
|
|
148
128
|
})
|
|
149
129
|
)
|
|
150
130
|
},
|
|
@@ -14,12 +14,10 @@ export default function (request, context) {
|
|
|
14
14
|
selectedAmount,
|
|
15
15
|
|
|
16
16
|
cryptos: [],
|
|
17
|
-
networks: [],
|
|
18
17
|
sourceAddress: '',
|
|
19
18
|
options: [],
|
|
20
19
|
|
|
21
20
|
selectedCrypto: null,
|
|
22
|
-
selectedNetwork: null,
|
|
23
21
|
|
|
24
22
|
currentCategory: 'cryptoWay',
|
|
25
23
|
|
|
@@ -81,7 +79,7 @@ export default function (request, context) {
|
|
|
81
79
|
actions: ['setResult', 'setTtl'],
|
|
82
80
|
},
|
|
83
81
|
onError: {
|
|
84
|
-
target: '
|
|
82
|
+
target: 'calculated',
|
|
85
83
|
},
|
|
86
84
|
},
|
|
87
85
|
},
|
|
@@ -106,11 +104,6 @@ export default function (request, context) {
|
|
|
106
104
|
actions: 'setCrypto',
|
|
107
105
|
internal: false,
|
|
108
106
|
},
|
|
109
|
-
SET_NETWORK: {
|
|
110
|
-
target: '.debouncing',
|
|
111
|
-
actions: 'setNetwork',
|
|
112
|
-
internal: false,
|
|
113
|
-
},
|
|
114
107
|
SET_ADDRESS: {
|
|
115
108
|
actions: 'setAddress',
|
|
116
109
|
internal: false,
|
|
@@ -131,51 +124,31 @@ export default function (request, context) {
|
|
|
131
124
|
actions: {
|
|
132
125
|
setInitData: assign((context, event) => {
|
|
133
126
|
const { paymentDetail } = context
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
.map((crypto) => ({
|
|
137
|
-
...crypto,
|
|
138
|
-
label: crypto.channel,
|
|
139
|
-
value: crypto.method,
|
|
140
|
-
icon: crypto.channel,
|
|
141
|
-
}))
|
|
142
|
-
const defaultNetworks = cryptos[0].networkName.map((value, i) => {
|
|
127
|
+
const currentPayment = paymentDetail.find((item) => item.transferType === 'deposit' && item.category === context.currentCategory)
|
|
128
|
+
const cryptos = currentPayment?.cryptoOptional?.map((value, i) => {
|
|
143
129
|
return {
|
|
144
|
-
|
|
145
|
-
value,
|
|
146
|
-
|
|
130
|
+
...currentPayment,
|
|
131
|
+
label: value,
|
|
132
|
+
network: currentPayment?.networkName[i],
|
|
133
|
+
icon: currentPayment.channel,
|
|
147
134
|
}
|
|
148
135
|
})
|
|
149
136
|
return {
|
|
150
137
|
cryptos,
|
|
151
|
-
networks: defaultNetworks,
|
|
152
138
|
selectedCrypto: cryptos[0],
|
|
153
|
-
selectedNetwork: defaultNetworks[0],
|
|
154
139
|
options: cryptos[0].optional,
|
|
155
140
|
}
|
|
156
141
|
}),
|
|
157
142
|
setCrypto: assign((context, event) => {
|
|
158
143
|
const { cryptos } = context
|
|
159
|
-
const selectedCrypto = cryptos.find((crypto) => crypto.
|
|
160
|
-
const networks = selectedCrypto?.networkName.map((value, i) => {
|
|
161
|
-
return {
|
|
162
|
-
label: selectedCrypto?.networkOptional?.[i],
|
|
163
|
-
value,
|
|
164
|
-
icon: value,
|
|
165
|
-
}
|
|
166
|
-
})
|
|
144
|
+
const selectedCrypto = cryptos.find((crypto) => crypto.label === event.data.label)
|
|
167
145
|
return {
|
|
168
|
-
networks,
|
|
169
146
|
selectedCrypto: selectedCrypto,
|
|
170
|
-
selectedNetwork: networks[0],
|
|
171
147
|
selectedAmount: null,
|
|
172
148
|
calculation: null,
|
|
173
149
|
options: selectedCrypto.optional,
|
|
174
150
|
}
|
|
175
151
|
}),
|
|
176
|
-
setNetwork: assign((context, event) => {
|
|
177
|
-
return { selectedNetwork: event.data }
|
|
178
|
-
}),
|
|
179
152
|
setAmount: assign((context, event) => {
|
|
180
153
|
// 現金網可自由填額度,grandTotalEnable 欄位感覺不再需要?
|
|
181
154
|
if (context.selectedCrypto?.grandTotalEnable === 1) {
|
|
@@ -230,18 +203,12 @@ export default function (request, context) {
|
|
|
230
203
|
},
|
|
231
204
|
guards: {
|
|
232
205
|
isCalculable: (context, event) => {
|
|
233
|
-
const { selectedCrypto,
|
|
234
|
-
return
|
|
235
|
-
selectedCrypto &&
|
|
236
|
-
selectedNetwork &&
|
|
237
|
-
selectedAmount &&
|
|
238
|
-
selectedCrypto.minimum <= +selectedAmount &&
|
|
239
|
-
+selectedAmount <= selectedCrypto.maximum
|
|
240
|
-
)
|
|
206
|
+
const { selectedCrypto, selectedAmount } = context
|
|
207
|
+
return selectedCrypto && selectedAmount && selectedCrypto.minimum <= +selectedAmount && +selectedAmount <= selectedCrypto.maximum
|
|
241
208
|
},
|
|
242
209
|
isSubmittable: (context, event) => {
|
|
243
|
-
const { selectedCrypto,
|
|
244
|
-
return selectedCrypto &&
|
|
210
|
+
const { selectedCrypto, selectedAmount, calculation } = context
|
|
211
|
+
return selectedCrypto && selectedAmount && calculation
|
|
245
212
|
},
|
|
246
213
|
},
|
|
247
214
|
services: {
|
|
@@ -257,13 +224,13 @@ export default function (request, context) {
|
|
|
257
224
|
)
|
|
258
225
|
},
|
|
259
226
|
submitDeposit: async (context, event) => {
|
|
260
|
-
const { selectedCrypto,
|
|
227
|
+
const { selectedCrypto, selectedAmount, sourceAddress, promotion } = context
|
|
261
228
|
return await request.send(
|
|
262
229
|
payment.submitDepositTransactionCrypto({
|
|
263
230
|
method: selectedCrypto.method,
|
|
264
231
|
amount: selectedAmount,
|
|
265
232
|
cryptoCurrency: selectedCrypto.channel,
|
|
266
|
-
cryptoNetwork:
|
|
233
|
+
cryptoNetwork: selectedCrypto.network,
|
|
267
234
|
sourceAddress: sourceAddress,
|
|
268
235
|
promotionsNo: promotion?.promotionsNo,
|
|
269
236
|
})
|