@unchainedshop/plugins 3.1.10 → 4.0.0-rc.2
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/lib/delivery/pick-mup.js +0 -2
- package/lib/delivery/pick-mup.js.map +1 -1
- package/lib/files/gridfs/module.d.ts +2 -2
- package/lib/files/gridfs/module.d.ts.map +1 -1
- package/lib/filters/local-search.d.ts.map +1 -1
- package/lib/filters/local-search.js +9 -2
- package/lib/filters/local-search.js.map +1 -1
- package/lib/payment/apple-iap/adapter.js +5 -12
- package/lib/payment/apple-iap/adapter.js.map +1 -1
- package/lib/payment/apple-iap/fix-periods.d.ts.map +1 -1
- package/lib/payment/apple-iap/fix-periods.js +3 -5
- package/lib/payment/apple-iap/fix-periods.js.map +1 -1
- package/lib/payment/apple-iap/handler-express.js +3 -3
- package/lib/payment/apple-iap/handler-express.js.map +1 -1
- package/lib/payment/apple-iap/handler-fastify.js +3 -3
- package/lib/payment/apple-iap/handler-fastify.js.map +1 -1
- package/lib/payment/apple-iap/module.d.ts +2 -2
- package/lib/payment/apple-iap/module.d.ts.map +1 -1
- package/lib/payment/braintree.js +3 -4
- package/lib/payment/braintree.js.map +1 -1
- package/lib/payment/cryptopay/db/CryptopayTransactions.d.ts +1 -2
- package/lib/payment/cryptopay/db/CryptopayTransactions.d.ts.map +1 -1
- package/lib/payment/cryptopay/db/CryptopayTransactions.js.map +1 -1
- package/lib/payment/cryptopay/de.d.ts +2 -0
- package/lib/payment/cryptopay/de.d.ts.map +1 -0
- package/lib/payment/cryptopay/de.js +10 -0
- package/lib/payment/cryptopay/de.js.map +1 -0
- package/lib/payment/cryptopay/denote-amount.d.ts +25 -0
- package/lib/payment/cryptopay/denote-amount.d.ts.map +1 -0
- package/lib/payment/cryptopay/denote-amount.js +31 -0
- package/lib/payment/cryptopay/denote-amount.js.map +1 -0
- package/lib/payment/cryptopay/derive-btc-address.d.ts +3 -0
- package/lib/payment/cryptopay/derive-btc-address.d.ts.map +1 -0
- package/lib/payment/cryptopay/derive-btc-address.js +39 -0
- package/lib/payment/cryptopay/derive-btc-address.js.map +1 -0
- package/lib/payment/cryptopay/derive-btc-address.test copy.d.ts +2 -0
- package/lib/payment/cryptopay/derive-btc-address.test copy.d.ts.map +1 -0
- package/lib/payment/cryptopay/derive-btc-address.test copy.js +10 -0
- package/lib/payment/cryptopay/derive-btc-address.test copy.js.map +1 -0
- package/lib/payment/cryptopay/derive-eth-address.d.ts +3 -0
- package/lib/payment/cryptopay/derive-eth-address.d.ts.map +1 -0
- package/lib/payment/cryptopay/derive-eth-address.js +32 -0
- package/lib/payment/cryptopay/derive-eth-address.js.map +1 -0
- package/lib/payment/cryptopay/handle-webhook.d.ts +26 -0
- package/lib/payment/cryptopay/handle-webhook.d.ts.map +1 -0
- package/lib/payment/cryptopay/handle-webhook.js +61 -0
- package/lib/payment/cryptopay/handle-webhook.js.map +1 -0
- package/lib/payment/cryptopay/handler-express.d.ts.map +1 -1
- package/lib/payment/cryptopay/handler-express.js +3 -56
- package/lib/payment/cryptopay/handler-express.js.map +1 -1
- package/lib/payment/cryptopay/handler-fastify.d.ts.map +1 -1
- package/lib/payment/cryptopay/handler-fastify.js +3 -55
- package/lib/payment/cryptopay/handler-fastify.js.map +1 -1
- package/lib/payment/cryptopay/module.d.ts +26 -26
- package/lib/payment/cryptopay/module.d.ts.map +1 -1
- package/lib/payment/cryptopay/module.js +26 -24
- package/lib/payment/cryptopay/module.js.map +1 -1
- package/lib/payment/cryptopay/plugin.d.ts.map +1 -1
- package/lib/payment/cryptopay/plugin.js +33 -79
- package/lib/payment/cryptopay/plugin.js.map +1 -1
- package/lib/payment/datatrans-v2/api/types.d.ts +41 -41
- package/lib/payment/datatrans-v2/api/types.d.ts.map +1 -1
- package/lib/payment/datatrans-v2/getPaths.d.ts +2 -2
- package/lib/payment/datatrans-v2/getPaths.d.ts.map +1 -1
- package/lib/payment/datatrans-v2/index.js +16 -14
- package/lib/payment/datatrans-v2/index.js.map +1 -1
- package/lib/payment/datatrans-v2/roundedAmountFromOrder.d.ts +1 -1
- package/lib/payment/datatrans-v2/roundedAmountFromOrder.d.ts.map +1 -1
- package/lib/payment/datatrans-v2/roundedAmountFromOrder.js +3 -3
- package/lib/payment/datatrans-v2/roundedAmountFromOrder.js.map +1 -1
- package/lib/payment/paypal-checkout.js +1 -1
- package/lib/payment/paypal-checkout.js.map +1 -1
- package/lib/payment/payrexx/api/index.d.ts +2 -2
- package/lib/payment/payrexx/api/index.d.ts.map +1 -1
- package/lib/payment/payrexx/api/makeFetcher.d.ts.map +1 -1
- package/lib/payment/payrexx/api/makeFetcher.js.map +1 -1
- package/lib/payment/payrexx/index.js +4 -4
- package/lib/payment/payrexx/index.js.map +1 -1
- package/lib/payment/payrexx/payrexx.js +2 -2
- package/lib/payment/payrexx/payrexx.js.map +1 -1
- package/lib/payment/postfinance-checkout/index.js +3 -5
- package/lib/payment/postfinance-checkout/index.js.map +1 -1
- package/lib/payment/postfinance-checkout/types.d.ts +4 -4
- package/lib/payment/postfinance-checkout/types.d.ts.map +1 -1
- package/lib/payment/postfinance-checkout/utils.js +2 -2
- package/lib/payment/postfinance-checkout/utils.js.map +1 -1
- package/lib/payment/saferpay/adapter.d.ts.map +1 -1
- package/lib/payment/saferpay/adapter.js +4 -6
- package/lib/payment/saferpay/adapter.js.map +1 -1
- package/lib/payment/saferpay/api/models/Transaction.d.ts +2 -2
- package/lib/payment/saferpay/api/models/Transaction.d.ts.map +1 -1
- package/lib/payment/saferpay/module.d.ts +2 -2
- package/lib/payment/saferpay/module.d.ts.map +1 -1
- package/lib/payment/stripe/index.js +5 -5
- package/lib/payment/stripe/index.js.map +1 -1
- package/lib/payment/stripe/stripe.js +3 -3
- package/lib/payment/stripe/stripe.js.map +1 -1
- package/lib/presets/all.d.ts +12 -12
- package/lib/presets/all.d.ts.map +1 -1
- package/lib/pricing/delivery-swiss-tax.d.ts.map +1 -1
- package/lib/pricing/delivery-swiss-tax.js +2 -2
- package/lib/pricing/delivery-swiss-tax.js.map +1 -1
- package/lib/pricing/order-delivery.js +1 -1
- package/lib/pricing/order-delivery.js.map +1 -1
- package/lib/pricing/order-discount.js +3 -3
- package/lib/pricing/order-discount.js.map +1 -1
- package/lib/pricing/order-items-discount.js +1 -1
- package/lib/pricing/order-items-discount.js.map +1 -1
- package/lib/pricing/order-items.js +1 -1
- package/lib/pricing/order-items.js.map +1 -1
- package/lib/pricing/order-payment.js +1 -1
- package/lib/pricing/order-payment.js.map +1 -1
- package/lib/pricing/order-round.d.ts +1 -1
- package/lib/pricing/order-round.d.ts.map +1 -1
- package/lib/pricing/order-round.js +8 -8
- package/lib/pricing/order-round.js.map +1 -1
- package/lib/pricing/product-catalog-price.d.ts +0 -1
- package/lib/pricing/product-catalog-price.d.ts.map +1 -1
- package/lib/pricing/product-catalog-price.js +6 -18
- package/lib/pricing/product-catalog-price.js.map +1 -1
- package/lib/pricing/product-price-rateconversion.js +2 -2
- package/lib/pricing/product-price-rateconversion.js.map +1 -1
- package/lib/pricing/product-round.d.ts +1 -1
- package/lib/pricing/product-round.d.ts.map +1 -1
- package/lib/pricing/product-round.js +2 -2
- package/lib/pricing/product-round.js.map +1 -1
- package/lib/pricing/product-swiss-tax.d.ts +1 -1
- package/lib/pricing/product-swiss-tax.d.ts.map +1 -1
- package/lib/pricing/product-swiss-tax.js +2 -2
- package/lib/pricing/product-swiss-tax.js.map +1 -1
- package/lib/warehousing/eth-minter.js +2 -2
- package/lib/warehousing/eth-minter.js.map +1 -1
- package/lib/worker/bulk-import.js +1 -1
- package/lib/worker/bulk-import.js.map +1 -1
- package/lib/worker/enrollment-order-generator.js +1 -1
- package/lib/worker/enrollment-order-generator.js.map +1 -1
- package/lib/worker/error-notifications.d.ts +4 -4
- package/lib/worker/error-notifications.d.ts.map +1 -1
- package/lib/worker/message.d.ts +1 -1
- package/lib/worker/message.d.ts.map +1 -1
- package/lib/worker/sms.js +16 -16
- package/lib/worker/sms.js.map +1 -1
- package/lib/worker/update-coinbase-rates.js +1 -1
- package/lib/worker/update-coinbase-rates.js.map +1 -1
- package/lib/worker/update-ecb-rates.js.map +1 -1
- package/package.json +37 -53
- package/src/delivery/pick-mup.ts +0 -2
- package/src/files/gridfs/module.ts +2 -2
- package/src/filters/local-search.ts +11 -2
- package/src/payment/apple-iap/adapter.ts +6 -13
- package/src/payment/apple-iap/fix-periods.ts +4 -7
- package/src/payment/apple-iap/handler-express.ts +3 -3
- package/src/payment/apple-iap/handler-fastify.ts +3 -3
- package/src/payment/apple-iap/module.ts +2 -2
- package/src/payment/braintree.ts +3 -4
- package/src/payment/cryptopay/db/CryptopayTransactions.ts +1 -2
- package/src/payment/cryptopay/denote-amount.test.ts +28 -0
- package/src/payment/cryptopay/denote-amount.ts +29 -0
- package/src/payment/cryptopay/derive-btc-address.test.ts +22 -0
- package/src/payment/cryptopay/derive-btc-address.ts +48 -0
- package/src/payment/cryptopay/derive-eth-address.test.ts +22 -0
- package/src/payment/cryptopay/derive-eth-address.ts +38 -0
- package/src/payment/cryptopay/handle-webhook.ts +103 -0
- package/src/payment/cryptopay/handler-express.ts +3 -69
- package/src/payment/cryptopay/handler-fastify.ts +5 -70
- package/src/payment/cryptopay/module.ts +44 -40
- package/src/payment/cryptopay/plugin.ts +50 -87
- package/src/payment/cryptopay/readme.md +23 -1
- package/src/payment/datatrans-v2/api/types.ts +41 -41
- package/src/payment/datatrans-v2/getPaths.ts +2 -2
- package/src/payment/datatrans-v2/index.ts +17 -15
- package/src/payment/datatrans-v2/roundedAmountFromOrder.ts +4 -4
- package/src/payment/paypal-checkout.ts +1 -1
- package/src/payment/payrexx/api/index.ts +2 -2
- package/src/payment/payrexx/api/makeFetcher.ts +1 -1
- package/src/payment/payrexx/index.ts +4 -4
- package/src/payment/payrexx/payrexx.ts +2 -2
- package/src/payment/postfinance-checkout/index.ts +3 -5
- package/src/payment/postfinance-checkout/types.ts +6 -6
- package/src/payment/postfinance-checkout/utils.ts +2 -2
- package/src/payment/saferpay/adapter.ts +4 -6
- package/src/payment/saferpay/api/models/Transaction.ts +2 -2
- package/src/payment/saferpay/module.ts +2 -2
- package/src/payment/stripe/index.ts +5 -5
- package/src/payment/stripe/stripe.ts +3 -3
- package/src/pricing/delivery-swiss-tax.ts +6 -2
- package/src/pricing/order-delivery.ts +1 -1
- package/src/pricing/order-discount.ts +3 -3
- package/src/pricing/order-items-discount.ts +1 -1
- package/src/pricing/order-items.ts +1 -1
- package/src/pricing/order-payment.ts +1 -1
- package/src/pricing/order-round.ts +9 -9
- package/src/pricing/product-catalog-price.ts +6 -25
- package/src/pricing/product-price-rateconversion.ts +2 -2
- package/src/pricing/product-round.ts +3 -3
- package/src/pricing/product-swiss-tax.test.ts +6 -6
- package/src/pricing/product-swiss-tax.ts +2 -2
- package/src/warehousing/eth-minter.ts +2 -2
- package/src/worker/bulk-import.ts +1 -1
- package/src/worker/enrollment-order-generator.ts +3 -3
- package/src/worker/error-notifications.ts +4 -4
- package/src/worker/heartbeat.ts +2 -2
- package/src/worker/message.ts +1 -1
- package/src/worker/push-notification.ts +2 -2
- package/src/worker/sms.ts +19 -17
- package/src/worker/update-coinbase-rates.ts +3 -6
- package/src/worker/update-ecb-rates.ts +3 -3
- package/src/worker/BaseWorker.ts +0 -116
- package/src/worker/EventListenerWorker.ts +0 -61
- package/src/worker/FailedRescheduler.ts +0 -80
- package/src/worker/IntervalWorker.ts +0 -54
package/lib/worker/sms.js
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import { WorkerAdapter, WorkerDirector } from '@unchainedshop/core';
|
|
2
|
-
import Twilio from 'twilio';
|
|
3
2
|
const { TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN, TWILIO_SMS_FROM } = process.env;
|
|
4
|
-
/* Potential: no need for twilio npm
|
|
5
|
-
curl -X POST "https://api.twilio.com/2010-04-01/Accounts/$TWILIO_ACCOUNT_SID/Messages.json" \
|
|
6
|
-
--data-urlencode "From=+15017122661" \
|
|
7
|
-
--data-urlencode "Body=Hi there" \
|
|
8
|
-
--data-urlencode "To=+15558675310" \
|
|
9
|
-
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
|
|
10
|
-
*/
|
|
11
3
|
const SmsWorkerPlugin = {
|
|
12
4
|
...WorkerAdapter,
|
|
13
5
|
key: 'shop.unchained.worker-plugin.sms',
|
|
@@ -34,25 +26,33 @@ const SmsWorkerPlugin = {
|
|
|
34
26
|
};
|
|
35
27
|
}
|
|
36
28
|
try {
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
29
|
+
const url = `https://api.twilio.com/2010-04-01/Accounts/${TWILIO_ACCOUNT_SID}/Messages.json`;
|
|
30
|
+
const response = await fetch(url, {
|
|
31
|
+
method: 'POST',
|
|
32
|
+
headers: {
|
|
33
|
+
Authorization: `Basic ${Buffer.from(`${TWILIO_ACCOUNT_SID}:${TWILIO_AUTH_TOKEN}`).toString('base64')}`,
|
|
34
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
35
|
+
},
|
|
36
|
+
body: new URLSearchParams({
|
|
37
|
+
Body: text || '',
|
|
38
|
+
From: from || TWILIO_SMS_FROM,
|
|
39
|
+
To: to,
|
|
40
|
+
}),
|
|
42
41
|
});
|
|
43
|
-
|
|
42
|
+
const data = await response.json();
|
|
43
|
+
if (!response.ok) {
|
|
44
44
|
return {
|
|
45
45
|
success: false,
|
|
46
46
|
error: {
|
|
47
47
|
name: 'TWILIO_ERROR',
|
|
48
|
-
message:
|
|
48
|
+
message: data.message || 'Failed to send SMS',
|
|
49
49
|
},
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
52
|
return {
|
|
53
53
|
success: true,
|
|
54
54
|
result: {
|
|
55
|
-
sid,
|
|
55
|
+
sid: data.sid,
|
|
56
56
|
},
|
|
57
57
|
error: null,
|
|
58
58
|
};
|
package/lib/worker/sms.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sms.js","sourceRoot":"","sources":["../../src/worker/sms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,aAAa,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"sms.js","sourceRoot":"","sources":["../../src/worker/sms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,aAAa,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAEpF,MAAM,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;AAE/E,MAAM,eAAe,GAOjB;IACF,GAAG,aAAa;IAEhB,GAAG,EAAE,kCAAkC;IACvC,KAAK,EAAE,2BAA2B;IAClC,OAAO,EAAE,OAAO;IAEhB,IAAI,EAAE,KAAK;IAEX,MAAM,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;QACnC,IAAI,CAAC,eAAe,IAAI,CAAC,IAAI,EAAE,CAAC;YAC9B,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE;oBACL,IAAI,EAAE,iBAAiB;oBACvB,OAAO,EAAE,8CAA8C;iBACxD;aACF,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,EAAE,EAAE,CAAC;YACR,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE;oBACL,IAAI,EAAE,oBAAoB;oBAC1B,OAAO,EAAE,mBAAmB;iBAC7B;aACF,CAAC;QACJ,CAAC;QAED,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,8CAA8C,kBAAkB,gBAAgB,CAAC;YAC7F,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;gBAChC,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE;oBACP,aAAa,EAAE,SAAS,MAAM,CAAC,IAAI,CAAC,GAAG,kBAAkB,IAAI,iBAAiB,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;oBACtG,cAAc,EAAE,mCAAmC;iBACpD;gBACD,IAAI,EAAE,IAAI,eAAe,CAAC;oBACxB,IAAI,EAAE,IAAI,IAAI,EAAE;oBAChB,IAAI,EAAE,IAAI,IAAI,eAAe;oBAC7B,EAAE,EAAE,EAAE;iBACP,CAAC;aACH,CAAC,CAAC;YAEH,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YAEnC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;gBACjB,OAAO;oBACL,OAAO,EAAE,KAAK;oBACd,KAAK,EAAE;wBACL,IAAI,EAAE,cAAc;wBACpB,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,oBAAoB;qBAC9C;iBACF,CAAC;YACJ,CAAC;YAED,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,MAAM,EAAE;oBACN,GAAG,EAAE,IAAI,CAAC,GAAG;iBACd;gBACD,KAAK,EAAE,IAAI;aACZ,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE;oBACL,IAAI,EAAE,GAAG,CAAC,IAAI;oBACd,OAAO,EAAE,GAAG,CAAC,OAAO;oBACpB,KAAK,EAAE,GAAG,CAAC,KAAK;iBACjB;aACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC;AAEF,cAAc,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC"}
|
|
@@ -20,7 +20,7 @@ const UpdateCoinbaseRates = {
|
|
|
20
20
|
const currencies = await unchainedAPI.modules.currencies.findCurrencies({ includeInactive: true });
|
|
21
21
|
const currencyCode = resolveBestCurrency(null, currencies); // Get fallback currency
|
|
22
22
|
const currencyCodes = currencies.map((currency) => currency.isoCode);
|
|
23
|
-
const { currency: baseCurrency, rates: pairs
|
|
23
|
+
const { currency: baseCurrency, rates: pairs } = await getExchangeRates(currencyCode);
|
|
24
24
|
const timestamp = new Date();
|
|
25
25
|
// five minutes
|
|
26
26
|
const expiresAt = new Date(new Date().getTime() + 5 * 60 * 1000);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-coinbase-rates.js","sourceRoot":"","sources":["../../src/worker/update-coinbase-rates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,aAAa,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACpF,OAAO,KAAK,MAAM,eAAe,CAAC;AAElC,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D,MAAM,gBAAgB,GAAG,KAAK,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"update-coinbase-rates.js","sourceRoot":"","sources":["../../src/worker/update-coinbase-rates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,aAAa,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACpF,OAAO,KAAK,MAAM,eAAe,CAAC;AAElC,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D,MAAM,gBAAgB,GAAG,KAAK,EAAE,IAAI,EAAgE,EAAE;IACpG,OAAO,KAAK,CAAC,uDAAuD,IAAI,EAAE,EAAE;QAC1E,MAAM,EAAE,KAAK;KACd,CAAC;SACC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;SACzB,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;AAC1B,CAAC,CAAC;AAEF,MAAM,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAElD,MAAM,mBAAmB,GAA6B;IACpD,GAAG,aAAa;IAEhB,GAAG,EAAE,6CAA6C;IAClD,KAAK,EAAE,uBAAuB;IAC9B,OAAO,EAAE,OAAO;IAChB,IAAI,EAAE,uBAAuB;IAE7B,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY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BACN,YAAY,EAAE,KAAK,CAAC,MAAM;iBAC3B;aACF,CAAC;QACJ,CAAC;QAAC,MAAM,CAAC;YACP,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE;oBACL,IAAI,EAAE,8BAA8B;oBACpC,OAAO,EAAE,gCAAgC;iBAC1C;aACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC;AAEF,cAAc,CAAC,eAAe,CAAC,mBAAmB,CAAC,CAAC;AAEpD,cAAc,CAAC,uBAAuB,CAAC;IACrC,IAAI,EAAE,mBAAmB,CAAC,IAAI;IAC9B,QAAQ,EAAE,WAAW;CACtB,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-ecb-rates.js","sourceRoot":"","sources":["../../src/worker/update-ecb-rates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,aAAa,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACpF,OAAO,KAAK,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAGlC,MAAM,gBAAgB,GAAG,KAAK,
|
|
1
|
+
{"version":3,"file":"update-ecb-rates.js","sourceRoot":"","sources":["../../src/worker/update-ecb-rates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,aAAa,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACpF,OAAO,KAAK,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAGlC,MAAM,gBAAgB,GAAG,KAAK,IAAmD,EAAE;IACjF,OAAO,KAAK,CAAC,+DAA+D,EAAE;QAC5E,MAAM,EAAE,KAAK;KACd,CAAC;SACC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;SACzB,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CA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json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/plugins",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-rc.2",
|
|
4
4
|
"main": "lib/plugins-index.js",
|
|
5
5
|
"types": "lib/plugins-index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -34,46 +34,45 @@
|
|
|
34
34
|
},
|
|
35
35
|
"homepage": "https://github.com/unchainedshop/unchained#readme",
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@
|
|
38
|
-
"@unchainedshop/
|
|
39
|
-
"@unchainedshop/core-
|
|
40
|
-
"@unchainedshop/core-
|
|
41
|
-
"@unchainedshop/core-
|
|
42
|
-
"@unchainedshop/core-
|
|
43
|
-
"@unchainedshop/core-
|
|
44
|
-
"@unchainedshop/core-
|
|
45
|
-
"@unchainedshop/
|
|
46
|
-
"@unchainedshop/
|
|
47
|
-
"@unchainedshop/
|
|
48
|
-
"@unchainedshop/
|
|
49
|
-
"@unchainedshop/utils": "^3.1.7",
|
|
37
|
+
"@unchainedshop/api": "^4.0.0-rc.2",
|
|
38
|
+
"@unchainedshop/core-delivery": "^4.0.0-rc.2",
|
|
39
|
+
"@unchainedshop/core-enrollments": "^4.0.0-rc.2",
|
|
40
|
+
"@unchainedshop/core-orders": "^4.0.0-rc.2",
|
|
41
|
+
"@unchainedshop/core-payment": "^4.0.0-rc.2",
|
|
42
|
+
"@unchainedshop/core-products": "^4.0.0-rc.2",
|
|
43
|
+
"@unchainedshop/core-warehousing": "^4.0.0-rc.2",
|
|
44
|
+
"@unchainedshop/core-worker": "^4.0.0-rc.2",
|
|
45
|
+
"@unchainedshop/events": "^4.0.0-rc.2",
|
|
46
|
+
"@unchainedshop/file-upload": "^4.0.0-rc.2",
|
|
47
|
+
"@unchainedshop/logger": "^4.0.0-rc.2",
|
|
48
|
+
"@unchainedshop/utils": "^4.0.0-rc.2",
|
|
50
49
|
"event-iterator": "^2.0.0",
|
|
51
50
|
"JSONStream": "^1.3.5"
|
|
52
51
|
},
|
|
53
52
|
"peerDependencies": {
|
|
53
|
+
"@breejs/later": "^4.2.0",
|
|
54
54
|
"@aws-sdk/client-eventbridge": ">= 3.714 < 4",
|
|
55
55
|
"@paypal/checkout-server-sdk": "1.x",
|
|
56
|
-
"@redis/client": "1
|
|
57
|
-
"bip32": "
|
|
58
|
-
"
|
|
59
|
-
"bs58check": "^4.0.0",
|
|
60
|
-
"ethers": ">= 6.13 < 7",
|
|
56
|
+
"@redis/client": ">= 1 < 6",
|
|
57
|
+
"@scure/bip32": ">= 1.7 < 2",
|
|
58
|
+
"@scure/btc-signer": ">= 1.8 < 2",
|
|
61
59
|
"expiry-map": "2.x",
|
|
62
60
|
"express": ">= 5 < 6",
|
|
63
61
|
"fastify": ">= 5.2 < 6",
|
|
64
|
-
"mime-types": ">=
|
|
62
|
+
"mime-types": ">= 2 < 4",
|
|
65
63
|
"minio": "8.x",
|
|
66
|
-
"nodemailer": ">= 6.9 <
|
|
64
|
+
"nodemailer": ">= 6.9 < 8",
|
|
67
65
|
"open": "10.x",
|
|
68
66
|
"p-memoize": "7.x",
|
|
69
67
|
"postfinancecheckout": ">= 4.5.0",
|
|
70
|
-
"stripe": "
|
|
71
|
-
"tiny-secp256k1": "2.x",
|
|
72
|
-
"twilio": "5.x",
|
|
68
|
+
"stripe": ">= 17 < 19",
|
|
73
69
|
"web-push": ">= 3.6 <4",
|
|
74
70
|
"xml-js": ">= 1.6 < 2"
|
|
75
71
|
},
|
|
76
72
|
"peerDependenciesMeta": {
|
|
73
|
+
"@breejs/later": {
|
|
74
|
+
"optional": true
|
|
75
|
+
},
|
|
77
76
|
"@aws-sdk/client-eventbridge": {
|
|
78
77
|
"optional": true
|
|
79
78
|
},
|
|
@@ -83,16 +82,10 @@
|
|
|
83
82
|
"@redis/client": {
|
|
84
83
|
"optional": true
|
|
85
84
|
},
|
|
86
|
-
"bip32": {
|
|
87
|
-
"optional": true
|
|
88
|
-
},
|
|
89
|
-
"bitcoinjs-lib": {
|
|
85
|
+
"@scure/bip32": {
|
|
90
86
|
"optional": true
|
|
91
87
|
},
|
|
92
|
-
"
|
|
93
|
-
"optional": true
|
|
94
|
-
},
|
|
95
|
-
"ethers": {
|
|
88
|
+
"@scure/btc-signer": {
|
|
96
89
|
"optional": true
|
|
97
90
|
},
|
|
98
91
|
"expiry-map": {
|
|
@@ -125,12 +118,6 @@
|
|
|
125
118
|
"stripe": {
|
|
126
119
|
"optional": true
|
|
127
120
|
},
|
|
128
|
-
"tiny-secp256k1": {
|
|
129
|
-
"optional": true
|
|
130
|
-
},
|
|
131
|
-
"twilio": {
|
|
132
|
-
"optional": true
|
|
133
|
-
},
|
|
134
121
|
"web-push": {
|
|
135
122
|
"optional": true
|
|
136
123
|
},
|
|
@@ -141,27 +128,24 @@
|
|
|
141
128
|
"devDependencies": {
|
|
142
129
|
"@breejs/later": "^4.2.0",
|
|
143
130
|
"@paypal/checkout-server-sdk": "^1.0.3",
|
|
144
|
-
"@redis/client": "^
|
|
131
|
+
"@redis/client": "^5.0.1",
|
|
132
|
+
"@scure/bip32": "^1.7.0",
|
|
133
|
+
"@scure/btc-signer": "^1.8.0",
|
|
134
|
+
"@types/breejs__later": "^4.1.5",
|
|
145
135
|
"@types/express": "^5.0.1",
|
|
146
|
-
"@types/node": "^22.
|
|
147
|
-
"bip32": "^5.0.0-rc.0",
|
|
148
|
-
"bitcoinjs-lib": "^6.1.7",
|
|
149
|
-
"bs58check": "^4.0.0",
|
|
150
|
-
"ethers": "^6.13.5",
|
|
136
|
+
"@types/node": "^22.15.3",
|
|
151
137
|
"expiry-map": "^2.0.0",
|
|
152
138
|
"express": "^5.1.0",
|
|
153
|
-
"fastify": "^5.
|
|
154
|
-
"mime-types": "^3.0.
|
|
139
|
+
"fastify": "^5.3.2",
|
|
140
|
+
"mime-types": "^3.0.1",
|
|
155
141
|
"minio": "^8.0.5",
|
|
156
|
-
"nodemailer": "^
|
|
157
|
-
"open": "^10.1.
|
|
142
|
+
"nodemailer": "^7.0.2",
|
|
143
|
+
"open": "^10.1.2",
|
|
158
144
|
"p-memoize": "^7.1.1",
|
|
159
145
|
"postfinancecheckout": "^4.7.0",
|
|
160
|
-
"stripe": "^
|
|
161
|
-
"
|
|
162
|
-
"
|
|
163
|
-
"twilio": "^5.5.1",
|
|
164
|
-
"typescript": "^5.8.2",
|
|
146
|
+
"stripe": "^18.1.0",
|
|
147
|
+
"tsx": "^4.19.4",
|
|
148
|
+
"typescript": "^5.8.3",
|
|
165
149
|
"web-push": "^3.6.7",
|
|
166
150
|
"xml-js": "^1.6.11"
|
|
167
151
|
}
|
package/src/delivery/pick-mup.ts
CHANGED
|
@@ -22,7 +22,6 @@ const fetchPickMupLocations = async (key: string, idsFilter?: string) => {
|
|
|
22
22
|
const { stores = [] } = result || {};
|
|
23
23
|
return stores.flatMap(({ markets = [], location = {}, id }) => {
|
|
24
24
|
return markets.map(({ full_name: fullName }) => {
|
|
25
|
-
// eslint-disable-line
|
|
26
25
|
const {
|
|
27
26
|
geo: { lat, lon },
|
|
28
27
|
zip,
|
|
@@ -90,7 +89,6 @@ const PickMup: IDeliveryAdapter = {
|
|
|
90
89
|
},
|
|
91
90
|
|
|
92
91
|
configurationError: () => {
|
|
93
|
-
// eslint-disable-line
|
|
94
92
|
if (!getKey()) {
|
|
95
93
|
return DeliveryError.INCOMPLETE_CONFIGURATION;
|
|
96
94
|
}
|
|
@@ -2,6 +2,10 @@ import { mongodb } from '@unchainedshop/mongodb';
|
|
|
2
2
|
import { ProductText } from '@unchainedshop/core-products';
|
|
3
3
|
import { AssortmentText } from '@unchainedshop/core-assortments';
|
|
4
4
|
import { FilterDirector, FilterAdapter, IFilterAdapter } from '@unchainedshop/core';
|
|
5
|
+
import { createLogger } from '@unchainedshop/logger';
|
|
6
|
+
import { isDocumentDBCompatModeEnabled } from '@unchainedshop/mongodb';
|
|
7
|
+
|
|
8
|
+
const logger = createLogger('unchained:core-filters:local-search');
|
|
5
9
|
|
|
6
10
|
const LocalSearch: IFilterAdapter = {
|
|
7
11
|
...FilterAdapter,
|
|
@@ -38,7 +42,6 @@ const LocalSearch: IFilterAdapter = {
|
|
|
38
42
|
return products.map(({ productId }) => productId);
|
|
39
43
|
},
|
|
40
44
|
|
|
41
|
-
// eslint-disable-next-line
|
|
42
45
|
searchAssortments: async ({ assortmentIds }) => {
|
|
43
46
|
const { queryString } = params.searchQuery;
|
|
44
47
|
|
|
@@ -89,4 +92,10 @@ const LocalSearch: IFilterAdapter = {
|
|
|
89
92
|
|
|
90
93
|
export default LocalSearch;
|
|
91
94
|
|
|
92
|
-
|
|
95
|
+
if (!isDocumentDBCompatModeEnabled()) {
|
|
96
|
+
FilterDirector.registerAdapter(LocalSearch);
|
|
97
|
+
} else {
|
|
98
|
+
logger.warn(
|
|
99
|
+
'Free text search queries have been disabled due to DocumentDB compatibility mode (env UNCHAINED_DOCUMENTDB_COMPAT_MODE is trueish)',
|
|
100
|
+
);
|
|
101
|
+
}
|
|
@@ -26,7 +26,6 @@ const AppleIAP: IPaymentAdapter = {
|
|
|
26
26
|
...PaymentAdapter.actions(params, context),
|
|
27
27
|
|
|
28
28
|
configurationError() {
|
|
29
|
-
// eslint-disable-line
|
|
30
29
|
if (!APPLE_IAP_SHARED_SECRET) {
|
|
31
30
|
return PaymentError.INCOMPLETE_CONFIGURATION;
|
|
32
31
|
}
|
|
@@ -38,23 +37,19 @@ const AppleIAP: IPaymentAdapter = {
|
|
|
38
37
|
return false;
|
|
39
38
|
},
|
|
40
39
|
|
|
41
|
-
// eslint-disable-next-line
|
|
42
40
|
isPayLaterAllowed() {
|
|
43
41
|
return false;
|
|
44
42
|
},
|
|
45
43
|
|
|
46
|
-
// eslint-disable-next-line
|
|
47
44
|
async sign() {
|
|
48
45
|
throw new Error('Apple IAP does not support payment signing');
|
|
49
46
|
},
|
|
50
47
|
|
|
51
|
-
// eslint-disable-next-line
|
|
52
48
|
async validate() {
|
|
53
49
|
// once registered receipt transactions are valid by default!
|
|
54
50
|
return true;
|
|
55
51
|
},
|
|
56
52
|
|
|
57
|
-
// eslint-disable-next-line
|
|
58
53
|
async register(transactionContext) {
|
|
59
54
|
const { receiptData } = transactionContext;
|
|
60
55
|
|
|
@@ -62,13 +57,13 @@ const AppleIAP: IPaymentAdapter = {
|
|
|
62
57
|
receiptData,
|
|
63
58
|
password: APPLE_IAP_SHARED_SECRET,
|
|
64
59
|
});
|
|
65
|
-
const { status, latest_receipt_info: latestReceiptInfo } = response;
|
|
60
|
+
const { status, latest_receipt_info: latestReceiptInfo } = response;
|
|
66
61
|
|
|
67
62
|
if (status === 0) {
|
|
68
63
|
logger.debug('Apple IAP Plugin: Receipt validated and updated for the user');
|
|
69
|
-
const latestTransaction = latestReceiptInfo[latestReceiptInfo.length - 1];
|
|
64
|
+
const latestTransaction = latestReceiptInfo[latestReceiptInfo.length - 1];
|
|
70
65
|
return {
|
|
71
|
-
token: latestTransaction.web_order_line_item_id,
|
|
66
|
+
token: latestTransaction.web_order_line_item_id,
|
|
72
67
|
latestReceiptInfo,
|
|
73
68
|
};
|
|
74
69
|
}
|
|
@@ -79,7 +74,6 @@ const AppleIAP: IPaymentAdapter = {
|
|
|
79
74
|
return null;
|
|
80
75
|
},
|
|
81
76
|
|
|
82
|
-
// eslint-disable-next-line
|
|
83
77
|
async charge(transactionContext) {
|
|
84
78
|
const { meta, paymentCredentials, receiptData } = transactionContext || {};
|
|
85
79
|
const { transactionIdentifier } = meta || {};
|
|
@@ -100,10 +94,9 @@ const AppleIAP: IPaymentAdapter = {
|
|
|
100
94
|
}
|
|
101
95
|
|
|
102
96
|
const transactions =
|
|
103
|
-
receiptResponse?.latest_receipt_info ||
|
|
104
|
-
paymentCredentials?.meta?.latestReceiptInfo;
|
|
97
|
+
receiptResponse?.latest_receipt_info || paymentCredentials?.meta?.latestReceiptInfo;
|
|
105
98
|
const matchedTransaction = transactions?.find(
|
|
106
|
-
(transaction) => transaction?.transaction_id === transactionIdentifier,
|
|
99
|
+
(transaction) => transaction?.transaction_id === transactionIdentifier,
|
|
107
100
|
);
|
|
108
101
|
if (!matchedTransaction) {
|
|
109
102
|
throw new Error(
|
|
@@ -131,7 +124,7 @@ const AppleIAP: IPaymentAdapter = {
|
|
|
131
124
|
|
|
132
125
|
const isMatchesTransaction =
|
|
133
126
|
parseInt(matchedTransaction.quantity, 10) === quantity &&
|
|
134
|
-
matchedTransaction.product_id === productId;
|
|
127
|
+
matchedTransaction.product_id === productId;
|
|
135
128
|
|
|
136
129
|
if (!isMatchesTransaction)
|
|
137
130
|
throw new Error('Apple IAP Plugin: Product in order does not match transaction');
|
|
@@ -4,17 +4,14 @@ export const fixPeriods = async (
|
|
|
4
4
|
{ transactionId, enrollmentId, orderId, transactions },
|
|
5
5
|
unchainedAPI: UnchainedCore,
|
|
6
6
|
) => {
|
|
7
|
-
const relevantTransactions = transactions.filter(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return original_transaction_id === transactionId; // eslint-disable-line
|
|
11
|
-
},
|
|
12
|
-
);
|
|
7
|
+
const relevantTransactions = transactions.filter(({ original_transaction_id }) => {
|
|
8
|
+
return original_transaction_id === transactionId;
|
|
9
|
+
});
|
|
13
10
|
|
|
14
11
|
const adjustedEnrollmentPeriods = relevantTransactions
|
|
15
12
|
.map((transaction) => {
|
|
16
13
|
return {
|
|
17
|
-
isTrial: transaction.is_trial_period === 'true',
|
|
14
|
+
isTrial: transaction.is_trial_period === 'true',
|
|
18
15
|
start: new Date(parseInt(transaction.purchase_date_ms, 10)),
|
|
19
16
|
end: new Date(parseInt(transaction.expires_date_ms, 10)),
|
|
20
17
|
orderId: transaction.transaction_id === transactionId ? orderId : null,
|
|
@@ -25,7 +25,7 @@ export const appleIAPHandler = async (req, res) => {
|
|
|
25
25
|
throw new Error('shared secret not valid');
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
const transactions = responseBody?.unified_receipt?.latest_receipt_info;
|
|
28
|
+
const transactions = responseBody?.unified_receipt?.latest_receipt_info;
|
|
29
29
|
const latestTransaction = transactions[0];
|
|
30
30
|
|
|
31
31
|
if (responseBody.notification_type === AppleNotificationTypes.INITIAL_BUY) {
|
|
@@ -40,7 +40,7 @@ export const appleIAPHandler = async (req, res) => {
|
|
|
40
40
|
|
|
41
41
|
const order = await services.orders.checkoutOrder(orderPayment.orderId, {
|
|
42
42
|
paymentContext: {
|
|
43
|
-
|
|
43
|
+
receiptData: responseBody?.unified_receipt?.latest_receipt,
|
|
44
44
|
},
|
|
45
45
|
});
|
|
46
46
|
const orderId = order._id;
|
|
@@ -78,7 +78,7 @@ export const appleIAPHandler = async (req, res) => {
|
|
|
78
78
|
|
|
79
79
|
await services.orders.registerPaymentCredentials(enrollment.payment.paymentProviderId, {
|
|
80
80
|
transactionContext: {
|
|
81
|
-
|
|
81
|
+
receiptData: responseBody?.unified_receipt?.latest_receipt,
|
|
82
82
|
},
|
|
83
83
|
userId: enrollment.userId,
|
|
84
84
|
});
|
|
@@ -33,7 +33,7 @@ export const appleIAPHandler: RouteHandlerMethod = async (
|
|
|
33
33
|
throw new Error('shared secret not valid');
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
const transactions = responseBody?.unified_receipt?.latest_receipt_info;
|
|
37
37
|
const latestTransaction = transactions[0];
|
|
38
38
|
|
|
39
39
|
if (responseBody.notification_type === AppleNotificationTypes.INITIAL_BUY) {
|
|
@@ -48,7 +48,7 @@ export const appleIAPHandler: RouteHandlerMethod = async (
|
|
|
48
48
|
|
|
49
49
|
const order = await services.orders.checkoutOrder(orderPayment.orderId, {
|
|
50
50
|
paymentContext: {
|
|
51
|
-
|
|
51
|
+
receiptData: responseBody?.unified_receipt?.latest_receipt,
|
|
52
52
|
},
|
|
53
53
|
});
|
|
54
54
|
const orderId = order._id;
|
|
@@ -86,7 +86,7 @@ export const appleIAPHandler: RouteHandlerMethod = async (
|
|
|
86
86
|
|
|
87
87
|
await services.orders.registerPaymentCredentials(enrollment.payment.paymentProviderId, {
|
|
88
88
|
transactionContext: {
|
|
89
|
-
|
|
89
|
+
receiptData: responseBody?.unified_receipt?.latest_receipt,
|
|
90
90
|
},
|
|
91
91
|
userId: enrollment.userId,
|
|
92
92
|
});
|
package/src/payment/braintree.ts
CHANGED
|
@@ -52,7 +52,6 @@ const BraintreeDirect: IPaymentAdapter = {
|
|
|
52
52
|
return BRAINTREE_SANDBOX_TOKEN;
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
-
// eslint-disable-next-line
|
|
56
55
|
const getPrivateKey = () => {
|
|
57
56
|
return BRAINTREE_PRIVATE_KEY;
|
|
58
57
|
};
|
|
@@ -114,17 +113,17 @@ const BraintreeDirect: IPaymentAdapter = {
|
|
|
114
113
|
|
|
115
114
|
// eslint-disable-next-line
|
|
116
115
|
// @ts-ignore
|
|
117
|
-
const braintree = (await import('braintree')).default;
|
|
116
|
+
const braintree = (await import('braintree')).default;
|
|
118
117
|
const gateway = getGateway(braintree);
|
|
119
118
|
const address = order.billingAddress;
|
|
120
119
|
const pricing = OrderPricingSheet({
|
|
121
120
|
calculation: order.calculation,
|
|
122
|
-
|
|
121
|
+
currencyCode: order.currencyCode,
|
|
123
122
|
});
|
|
124
123
|
const rounded = Math.round(pricing.total({ useNetPrice: false }).amount / 10 || 0) * 10;
|
|
125
124
|
const saleRequest = {
|
|
126
125
|
amount: rounded / 100,
|
|
127
|
-
merchantAccountId: order.
|
|
126
|
+
merchantAccountId: order.currencyCode,
|
|
128
127
|
paymentMethodNonce: paypalPaymentMethodNonce,
|
|
129
128
|
orderId: order.orderNumber || order._id,
|
|
130
129
|
shipping: address
|
|
@@ -6,9 +6,8 @@ export type CryptopayTransaction = {
|
|
|
6
6
|
blockHeight: number;
|
|
7
7
|
mostRecentBlockHeight: number;
|
|
8
8
|
amount: mongodb.Decimal128;
|
|
9
|
-
|
|
9
|
+
currencyCode: string;
|
|
10
10
|
decimals: number;
|
|
11
|
-
contract: string;
|
|
12
11
|
orderPaymentId?: string;
|
|
13
12
|
} & TimestampFields;
|
|
14
13
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { describe, it } from 'node:test';
|
|
2
|
+
import assert from 'node:assert';
|
|
3
|
+
import denoteAmount from './denote-amount.js';
|
|
4
|
+
|
|
5
|
+
describe('Denote Amount', () => {
|
|
6
|
+
it('Handle amount with 18 decimals', () => {
|
|
7
|
+
// For example, Ethereum uses 18 decimals, this converts WEI to GWei
|
|
8
|
+
assert.equal(denoteAmount('1000000000000000000', 18), 1000000000n);
|
|
9
|
+
assert.equal(denoteAmount('100000000000000', 18), 100000n);
|
|
10
|
+
assert.equal(denoteAmount('100', 18), 0n);
|
|
11
|
+
});
|
|
12
|
+
it('Handle amount with 10 decimals', () => {
|
|
13
|
+
assert.equal(denoteAmount('100000000', 10), 10000000n);
|
|
14
|
+
assert.equal(denoteAmount('100000000000000', 10), 10000000000000n);
|
|
15
|
+
assert.equal(denoteAmount('100', 10), 10n);
|
|
16
|
+
});
|
|
17
|
+
it('Handle amount with 8 decimals', () => {
|
|
18
|
+
// For example, Bitcoin uses 8 decimals, this keeps Satoshi as is
|
|
19
|
+
assert.equal(denoteAmount('100000000', 8), 100000000n);
|
|
20
|
+
assert.equal(denoteAmount('100000000000000', 8), 100000000000000n);
|
|
21
|
+
assert.equal(denoteAmount('1', 8), 1n);
|
|
22
|
+
});
|
|
23
|
+
it('Handle amount with 2 decimals', () => {
|
|
24
|
+
assert.equal(denoteAmount('100000000', 2), 100000000n);
|
|
25
|
+
assert.equal(denoteAmount('100000000000000', 2), 100000000000000n);
|
|
26
|
+
assert.equal(denoteAmount('1', 2), 1n);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a cryptocurrency amount from its smallest unit (e.g., wei, satoshi) to a normalized value
|
|
3
|
+
* with 9 decimal places of precision.
|
|
4
|
+
*
|
|
5
|
+
* This function handles the denomination of cryptocurrency amounts by converting from the
|
|
6
|
+
* blockchain's native smallest units (like wei for Ethereum which is 10^-18 ETH, or satoshi for Bitcoin
|
|
7
|
+
* which is 10^-8 BTC) to a standardized format with 9 decimal places for consistent handling across
|
|
8
|
+
* different cryptocurrencies.
|
|
9
|
+
*
|
|
10
|
+
* @param {string} amountAsString - The amount in the cryptocurrency's smallest unit (e.g., wei, satoshi)
|
|
11
|
+
* represented as a string to handle large numbers
|
|
12
|
+
* @param {number} decimals - The number of decimal places used by the cryptocurrency
|
|
13
|
+
* (e.g., 18 for Ethereum, 8 for Bitcoin)
|
|
14
|
+
* @returns {number} The converted amount with 9 decimal places of precision
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // Convert 1 ETH in wei (1000000000000000000) to normalized format
|
|
18
|
+
* denoteAmount("1000000000000000000", 18)
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* // Convert 1 BTC in satoshi (100000000) to normalized format
|
|
22
|
+
* denoteAmount("100000000", 8)
|
|
23
|
+
*/
|
|
24
|
+
export default function denoteAmount(amountAsString: string, decimals: number) {
|
|
25
|
+
if (decimals <= 9) return BigInt(amountAsString); // No conversion needed if decimals are 9 or less
|
|
26
|
+
const exponent = BigInt(decimals) - 9n;
|
|
27
|
+
const amount = BigInt(amountAsString);
|
|
28
|
+
return amount / 10n ** exponent; // Denote to 9 decimals
|
|
29
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { describe, it } from 'node:test';
|
|
2
|
+
import assert from 'node:assert';
|
|
3
|
+
import deriveBtcAddress from './derive-btc-address.js';
|
|
4
|
+
|
|
5
|
+
describe('BTC Address Derivation', () => {
|
|
6
|
+
it('returns a deterministic BIP44 child address', () => {
|
|
7
|
+
assert.equal(
|
|
8
|
+
deriveBtcAddress(
|
|
9
|
+
'zpub6qpRm6gMdkrXvVKw7qgayHnqJGJkpE4rnYQdyJfZW87ed4Fk6HjVaThN12hv2rrL3EzfvvBW6ZpbMEe5UxZYEjhgeMigyvAbS5LiXPkKrys',
|
|
10
|
+
1,
|
|
11
|
+
),
|
|
12
|
+
'bc1qspcam3ntdpvhgz4vnxfdhas6qr8hf8tjfaz5p4',
|
|
13
|
+
);
|
|
14
|
+
assert.equal(
|
|
15
|
+
deriveBtcAddress(
|
|
16
|
+
'zpub6qpRm6gMdkrXvVKw7qgayHnqJGJkpE4rnYQdyJfZW87ed4Fk6HjVaThN12hv2rrL3EzfvvBW6ZpbMEe5UxZYEjhgeMigyvAbS5LiXPkKrys',
|
|
17
|
+
2,
|
|
18
|
+
),
|
|
19
|
+
'bc1qd0a7znq3pz3sc4armthddkyam57ey7qjc4v6vn',
|
|
20
|
+
);
|
|
21
|
+
});
|
|
22
|
+
});
|