@jetthai/cuora 1.1.262 → 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,10 @@
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
+
7
+ ### [1.1.263](https://github.com/jetthai/cuora-module/compare/v1.1.262...v1.1.263) (2024-05-10)
8
+
5
9
  ### [1.1.262](https://github.com/jetthai/cuora-module/compare/v1.1.261...v1.1.262) (2024-05-10)
6
10
 
7
11
  ### [1.1.261](https://github.com/jetthai/cuora-module/compare/v1.1.260...v1.1.261) (2024-05-09)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.262",
3
+ "version": "1.1.264",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -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 payments = paymentDetail.filter((item) => item.category === context.currentCategory)
85
- const currentPayment = payments[0]
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
- label: currentPayment.networkOptional?.[i],
90
- value,
91
- icon: value,
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.channel === event.data.channel)
106
- const networks =
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, selectedNetwork } = context
125
- return { result: resultMap[selectedNetwork.value] }
99
+ const { resultMap, selectedCrypto } = context
100
+ return { result: resultMap[selectedCrypto.network] }
126
101
  }),
127
102
  setResult: assign((context, event) => {
128
- const { resultMap, selectedNetwork } = context
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
- [selectedNetwork.value]: result,
119
+ [selectedCrypto.network]: result,
145
120
  },
146
121
  }
147
122
  }),
148
123
  },
149
124
  guards: {
150
125
  isFound: (context, event) => {
151
- const { resultMap, selectedNetwork } = context
152
- return resultMap[selectedNetwork.value]
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, selectedNetwork } = context
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: selectedNetwork.value,
140
+ cryptoNetwork: selectedCrypto.network,
166
141
  })
167
142
  )
168
143
  },
@@ -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 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) => {
72
+ const currentPayment = paymentDetail.find((item) => item.category === context.currentCategory)
73
+ const cryptos = currentPayment?.cryptoOptional?.map((value, i) => {
78
74
  return {
79
- label: currentPayment.networkOptional?.[i],
80
- value,
81
- icon: value,
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.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 }
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, selectedNetwork } = context
115
- return { result: resultMap[`${selectedCrypto.value}_${selectedNetwork.value}`] }
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, selectedNetwork } = context
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.value}_${selectedNetwork.value}`]: result,
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, selectedNetwork } = context
134
- return resultMap[`${selectedCrypto.value}_${selectedNetwork.value}`]
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 { currentPayment, selectedNetwork } = context
122
+ const { selectedCrypto } = context
143
123
  return await request.send(
144
124
  payment.submitDepositTransactionCrypto({
145
- method: currentPayment.method,
146
- cryptoCurrency: currentPayment.channel,
147
- cryptoNetwork: selectedNetwork.value,
125
+ method: selectedCrypto.method,
126
+ cryptoCurrency: selectedCrypto.channel,
127
+ cryptoNetwork: selectedCrypto.network,
148
128
  })
149
129
  )
150
130
  },
@@ -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 cryptos =
132
- event.data
133
- .filter((element) => element.category === context.currentCategory)
134
- .map?.((crypto) => ({ ...crypto, label: crypto.channel, value: crypto.method, icon: crypto.channel })) || []
135
- const currentPayment = cryptos.find((element) => element.category === context.currentCategory)
136
- const defaultNetworks =
137
- cryptos[0].networkName.map((value, i) => {
138
- return {
139
- label: cryptos[0].networkOptional?.[i],
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, selectedNetwork } = context
154
- const method = cryptos.find((crypto) => crypto.method === event.data.value)
155
- const networks =
156
- method?.networkName.map((value, i) => {
157
- return {
158
- label: method?.networkOptional?.[i],
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 && selectedNetwork && amount && minimum <= +amount && +amount <= maximum
188
+ return selectedCrypto && amount && minimum <= +amount && +amount <= maximum
221
189
  },
222
190
  isSubmittable: (context, event) => {
223
- const { selectedCrypto, selectedNetwork, amount } = context
224
- return selectedCrypto && selectedNetwork && amount
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, selectedNetwork, amount } = context
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: selectedNetwork.value,
217
+ cryptoNetwork: selectedCrypto.network,
250
218
  })
251
219
  )
252
220
  },
@@ -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: 'loaded',
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 cryptos = paymentDetail
135
- .filter((element) => element.transferType === 'deposit' && element.category === context.currentCategory)
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
- label: cryptos[0].networkOptional?.[i],
145
- value,
146
- icon: value,
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.method === event.data.value)
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, selectedNetwork, selectedAmount } = context
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, selectedNetwork, selectedAmount, calculation } = context
244
- return selectedCrypto && selectedNetwork && selectedAmount && calculation
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, selectedNetwork, selectedAmount, sourceAddress, promotion } = context
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: selectedNetwork.value,
233
+ cryptoNetwork: selectedCrypto.network,
267
234
  sourceAddress: sourceAddress,
268
235
  promotionsNo: promotion?.promotionsNo,
269
236
  })