@jetthai/cuora 1.1.256 → 1.1.258

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.258](https://github.com/jetthai/cuora-module/compare/v1.1.257...v1.1.258) (2024-05-07)
6
+
7
+ ### [1.1.257](https://github.com/jetthai/cuora-module/compare/v1.1.256...v1.1.257) (2024-05-06)
8
+
5
9
  ### [1.1.256](https://github.com/jetthai/cuora-module/compare/v1.1.255...v1.1.256) (2024-05-03)
6
10
 
7
11
  ### [1.1.255](https://github.com/jetthai/cuora-module/compare/v1.1.254...v1.1.255) (2024-05-03)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.256",
3
+ "version": "1.1.258",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -91,7 +91,7 @@ export default {
91
91
  method: 'post',
92
92
  params: { transferType: 'DEPOSIT', amount, cryptoCurrency, cryptoNetwork, sourceAddress, promotionsNo, receipt },
93
93
  }),
94
- submitDepositTransactionCryptoBank: ({ method, amount, cryptoCurrency, cryptoNetwork, sourceAddress, promotionsNo, depositTime, receipt }) => ({
94
+ submitDepositTransactionCryptoBank: ({ method, amount, cryptoCurrency, cryptoNetwork, targetAddress, promotionsNo, depositTime, receipt }) => ({
95
95
  url: `payment/v2/${method}/transaction`,
96
96
  method: 'post',
97
97
  params: {
@@ -99,7 +99,7 @@ export default {
99
99
  amount,
100
100
  cryptoCurrency,
101
101
  cryptoNetwork,
102
- sourceAddress,
102
+ targetAddress,
103
103
  promotionsNo,
104
104
  depositTime,
105
105
  receipt,
@@ -12,11 +12,9 @@ export default function (request) {
12
12
  paymentDetails: [],
13
13
 
14
14
  cryptos: [],
15
- networks: [],
16
-
15
+ cryptoBank: null,
17
16
  amount: null,
18
17
  selectedCrypto: null,
19
- selectedNetwork: null,
20
18
  selectedBank: null,
21
19
 
22
20
  currentCategory: 'cryptoBank',
@@ -123,10 +121,6 @@ export default function (request) {
123
121
  target: '.loaded',
124
122
  actions: 'setCrypto',
125
123
  },
126
- SET_NETWORK: {
127
- target: '.loaded',
128
- actions: 'setNetwork',
129
- },
130
124
  SET_AMOUNT: {
131
125
  target: '.loaded',
132
126
  actions: ['setAmount', 'clearCalculation'],
@@ -149,60 +143,38 @@ export default function (request) {
149
143
  {
150
144
  actions: {
151
145
  setPayment: assign((context, event) => {
152
- const cryptos =
153
- event.data
154
- .filter((element) => element.category === context.currentCategory)
155
- .map?.((crypto) => ({ ...crypto, label: crypto.channel, value: crypto.method, icon: crypto.channel })) || []
156
- const currentPayment = cryptos[0].networkName.map((value, i) => {
157
- return {
158
- label: cryptos[0].networkOptional?.[i],
159
- value,
160
- icon: value,
161
- }
162
- })
163
- const defaultNetworks =
164
- cryptos[0].networkName.map((value, i) => {
165
- return {
166
- label: cryptos[0].networkOptional?.[i],
167
- value,
168
- icon: value,
169
- }
170
- }) || []
171
- const selectedBank = (cryptos[0]?.banks || []).find((item) => item.network === defaultNetworks[0].value)
146
+ const cryptoBank = event.data.find((element) => element.category === context.currentCategory)
147
+ const cryptos = cryptoBank.banks.map((crypto) => ({
148
+ ...crypto,
149
+ label: crypto.cryptoName,
150
+ value: cryptoBank.method,
151
+ icon: crypto.symbol,
152
+ }))
153
+ const currentPayment = {
154
+ label: cryptos[0].network,
155
+ value: cryptos[0].network,
156
+ icon: cryptos[0].network,
157
+ }
172
158
 
173
159
  return {
174
160
  cryptos,
175
- networks: defaultNetworks,
161
+ cryptoBank,
176
162
  selectedCrypto: cryptos[0],
177
- selectedNetwork: defaultNetworks[0],
178
- selectedBank: selectedBank,
179
163
  options: cryptos[0].optional,
180
164
  currentPayment,
181
165
  processing: currentPayment.processing?.[0],
182
166
  }
183
167
  }),
184
168
  setCrypto: assign((context, event) => {
185
- const { cryptos } = context
186
- const selectedCrypto = cryptos.find((crypto) => crypto.method === event.data.value)
187
- const networks = selectedCrypto?.networkName.map((value, i) => {
188
- return {
189
- label: selectedCrypto?.networkOptional?.[i],
190
- value,
191
- icon: value,
192
- }
193
- })
169
+ const { cryptos, cryptoBank } = context
170
+ const selectedCrypto = cryptos.find((crypto) => crypto.address === event.data.address)
194
171
  return {
195
- networks,
196
172
  selectedCrypto: selectedCrypto,
197
- selectedNetwork: networks[0],
198
173
  selectedAmount: null,
199
174
  calculation: null,
200
- options: selectedCrypto.optional,
175
+ options: cryptoBank.optional,
201
176
  }
202
177
  }),
203
- setNetwork: assign((context, event) => {
204
- return { selectedNetwork: event.data }
205
- }),
206
178
  setAmount: assign((context, event) => {
207
179
  return {
208
180
  amount: event.data,
@@ -242,17 +214,12 @@ export default function (request) {
242
214
  },
243
215
  guards: {
244
216
  isCalculable: (context, event) => {
245
- const {
246
- selectedCrypto,
247
- selectedNetwork,
248
- amount,
249
- currentPayment: { maximum, minimum },
250
- } = context
251
- return selectedCrypto && selectedNetwork && amount && minimum <= +amount && +amount <= maximum
217
+ const { selectedCrypto, cryptoBank, amount } = context
218
+ return selectedCrypto && amount && cryptoBank.minimum <= +amount && +amount <= cryptoBank.maximum
252
219
  },
253
220
  isSubmittable: (context, event) => {
254
- const { selectedCrypto, selectedNetwork, amount, depositTime, receipt } = context
255
- return selectedCrypto && selectedNetwork && amount && depositTime && receipt
221
+ const { selectedCrypto, amount, depositTime, receipt } = context
222
+ return selectedCrypto && amount && depositTime && receipt
256
223
  },
257
224
  isProcessing: (context, event) => {
258
225
  return context.processing
@@ -266,21 +233,23 @@ export default function (request) {
266
233
  const { selectedCrypto, amount, promotion } = context
267
234
  return await request.send(
268
235
  payment.getCryptoDepositExpectedResult({
269
- method: selectedCrypto.method,
236
+ method: selectedCrypto.value,
270
237
  amount,
271
- cryptoCurrency: selectedCrypto.channel,
238
+ cryptoCurrency: selectedCrypto.symbol,
272
239
  promotionsNo: promotion?.activityNo,
273
240
  })
274
241
  )
275
242
  },
276
243
  submitDeposit: async (context, event) => {
277
- const { selectedCrypto, selectedNetwork, depositTime, receipt, amount } = context
244
+ const { selectedCrypto, depositTime, receipt, amount, promotion } = context
278
245
  return await request.send(
279
- payment.submitDepositTransactionCrypto({
280
- method: selectedCrypto.method,
246
+ payment.submitDepositTransactionCryptoBank({
247
+ method: selectedCrypto.value,
281
248
  amount: amount,
282
- cryptoCurrency: selectedCrypto.channel,
283
- cryptoNetwork: selectedNetwork.value,
249
+ cryptoCurrency: selectedCrypto.symbol,
250
+ cryptoNetwork: selectedCrypto.network,
251
+ targetAddress: selectedCrypto.address,
252
+ promotionsNo: promotion?.activityNo,
284
253
  depositTime,
285
254
  receipt,
286
255
  })
@@ -14,11 +14,9 @@ export default function (request, context) {
14
14
  selectedAmount,
15
15
 
16
16
  cryptos: [],
17
- networks: [],
18
17
  options: [],
19
-
18
+ cryptoBank: null,
20
19
  selectedCrypto: null,
21
- selectedNetwork: null,
22
20
 
23
21
  currentCategory: 'cryptoBank',
24
22
 
@@ -97,11 +95,6 @@ export default function (request, context) {
97
95
  actions: 'setCrypto',
98
96
  internal: false,
99
97
  },
100
- SET_NETWORK: {
101
- target: '.debouncing',
102
- actions: 'setNetwork',
103
- internal: false,
104
- },
105
98
  SET_AMOUNT: {
106
99
  target: '.debouncing',
107
100
  actions: 'setAmount',
@@ -124,54 +117,33 @@ export default function (request, context) {
124
117
  actions: {
125
118
  setInitData: assign((context, event) => {
126
119
  const { paymentDetail } = context
127
- const cryptos = paymentDetail
128
- .filter((element) => element.transferType === 'deposit' && element.category === context.currentCategory)
129
- .map((crypto) => ({
130
- ...crypto,
131
- label: crypto.channel,
132
- value: crypto.method,
133
- icon: crypto.channel,
134
- }))
135
- const defaultNetworks = cryptos[0].networkName.map((value, i) => {
136
- return {
137
- label: cryptos[0].networkOptional?.[i],
138
- value,
139
- icon: value,
140
- }
141
- })
120
+ const cryptoBank = paymentDetail.find((element) => element.transferType === 'deposit' && element.category === context.currentCategory)
121
+ const cryptos = cryptoBank.banks.map((crypto) => ({
122
+ ...crypto,
123
+ label: crypto.cryptoName,
124
+ value: cryptoBank.method,
125
+ icon: crypto.symbol,
126
+ }))
142
127
  return {
143
128
  cryptos,
144
- networks: defaultNetworks,
129
+ cryptoBank,
145
130
  selectedCrypto: cryptos[0],
146
- selectedNetwork: defaultNetworks[0],
147
- options: cryptos[0].optional,
131
+ options: cryptoBank.optional,
148
132
  }
149
133
  }),
150
134
  setCrypto: assign((context, event) => {
151
- const { cryptos } = context
152
- const selectedCrypto = cryptos.find((crypto) => crypto.method === event.data.value)
153
- const networks = selectedCrypto?.networkName.map((value, i) => {
154
- return {
155
- label: selectedCrypto?.networkOptional?.[i],
156
- value,
157
- icon: value,
158
- }
159
- })
135
+ const { cryptos, cryptoBank } = context
136
+ const selectedCrypto = cryptos.find((crypto) => crypto.address === event.data.address)
160
137
  return {
161
- networks,
162
138
  selectedCrypto: selectedCrypto,
163
- selectedNetwork: networks[0],
164
139
  selectedAmount: null,
165
140
  calculation: null,
166
- options: selectedCrypto.optional,
141
+ options: cryptoBank.optional,
167
142
  }
168
143
  }),
169
- setNetwork: assign((context, event) => {
170
- return { selectedNetwork: event.data }
171
- }),
172
144
  setAmount: assign((context, event) => {
173
145
  // 現金網可自由填額度,grandTotalEnable 欄位感覺不再需要?
174
- if (context.selectedCrypto?.grandTotalEnable === 1) {
146
+ if (context.cryptoBank?.grandTotalEnable === 1) {
175
147
  return { selectedAmount: parseFloat(context.selectedAmount || 0) + parseFloat(event.data) }
176
148
  } else {
177
149
  return { selectedAmount: event.data }
@@ -196,11 +168,11 @@ export default function (request, context) {
196
168
  }
197
169
  }),
198
170
  setPromotion: assign((context, event) => {
199
- const { selectedCrypto, selectedAmount } = context
171
+ const { cryptoBank, selectedAmount } = context
200
172
  const promotion = event.data
201
173
  return {
202
174
  promotion,
203
- selectedAmount: max(promotion.minimumAmount, selectedCrypto.minimum, selectedAmount, 0),
175
+ selectedAmount: max(promotion.minimumAmount, cryptoBank.minimum, selectedAmount, 0),
204
176
  calculation: null,
205
177
  }
206
178
  }),
@@ -217,18 +189,12 @@ export default function (request, context) {
217
189
  },
218
190
  guards: {
219
191
  isCalculable: (context, event) => {
220
- const { selectedCrypto, selectedNetwork, selectedAmount } = context
221
- return (
222
- selectedCrypto &&
223
- selectedNetwork &&
224
- selectedAmount &&
225
- selectedCrypto.minimum <= +selectedAmount &&
226
- +selectedAmount <= selectedCrypto.maximum
227
- )
192
+ const { selectedCrypto, cryptoBank, selectedAmount } = context
193
+ return selectedCrypto && selectedAmount && cryptoBank.minimum <= +selectedAmount && +selectedAmount <= cryptoBank.maximum
228
194
  },
229
195
  isSubmittable: (context, event) => {
230
- const { selectedCrypto, selectedNetwork, selectedAmount, depositTime, receipt, calculation } = context
231
- return selectedCrypto && selectedNetwork && selectedAmount && depositTime && receipt && calculation
196
+ const { selectedCrypto, selectedAmount, depositTime, receipt, calculation } = context
197
+ return selectedCrypto && selectedAmount && depositTime && receipt && calculation
232
198
  },
233
199
  },
234
200
  services: {
@@ -236,21 +202,22 @@ export default function (request, context) {
236
202
  const { selectedCrypto, selectedAmount, promotion } = context
237
203
  return await request.send(
238
204
  payment.getCryptoDepositExpectedResult({
239
- method: selectedCrypto.method,
205
+ method: selectedCrypto.value,
240
206
  amount: selectedAmount,
241
- cryptoCurrency: selectedCrypto.channel,
207
+ cryptoCurrency: selectedCrypto.symbol,
242
208
  promotionsNo: promotion?.promotionsNo,
243
209
  })
244
210
  )
245
211
  },
246
212
  submitDeposit: async (context, event) => {
247
- const { selectedCrypto, selectedNetwork, selectedAmount, promotion, depositTime, receipt } = context
213
+ const { selectedCrypto, selectedAmount, promotion, depositTime, receipt } = context
248
214
  return await request.send(
249
215
  payment.submitDepositTransactionCryptoBank({
250
- method: selectedCrypto.method,
216
+ method: selectedCrypto.value,
251
217
  amount: selectedAmount,
252
- cryptoCurrency: selectedCrypto.channel,
253
- cryptoNetwork: selectedNetwork.value,
218
+ cryptoCurrency: selectedCrypto.symbol,
219
+ cryptoNetwork: selectedCrypto.network,
220
+ targetAddress: selectedCrypto.address,
254
221
  promotionsNo: promotion?.promotionsNo,
255
222
  depositTime,
256
223
  receipt,