@blocklet/payment-react 1.17.3 → 1.17.5

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.
@@ -75,7 +75,7 @@ function OverdueInvoicePayment({
75
75
  }
76
76
  setSelectCurrencyId(currency.id);
77
77
  setPayLoading(true);
78
- if (method.type === "arcblock" || method.type === "ethereum") {
78
+ if (["arcblock", "ethereum", "base"].includes(method.type)) {
79
79
  connect.open({
80
80
  containerEl: void 0,
81
81
  saveConnect: false,
@@ -12,7 +12,7 @@ export type PaymentContextType = {
12
12
  connect: import('@arcblock/did-connect/lib/types').SessionContext['connectApi'];
13
13
  prefix: string;
14
14
  settings: Settings;
15
- refresh: () => void;
15
+ refresh: (forceRefresh?: boolean) => void;
16
16
  getCurrency: (currencyId: string) => TPaymentCurrency | undefined;
17
17
  getMethod: (methodId: string) => TPaymentMethodExpanded | undefined;
18
18
  setLivemode: (livemode: boolean) => void;
@@ -7,11 +7,11 @@ import { getPrefix } from "../libs/util.js";
7
7
  const PaymentContext = createContext({ api });
8
8
  const { Provider, Consumer } = PaymentContext;
9
9
  let settingsPromise = null;
10
- const getSettings = () => {
10
+ const getSettings = (forceRefresh = false) => {
11
11
  const livemode = localStorage.getItem("livemode") !== "false";
12
12
  const cacheKey = `payment-settings-${window.location.pathname}-${livemode}`;
13
13
  const cachedData = sessionStorage.getItem(cacheKey);
14
- if (cachedData) {
14
+ if (cachedData && !forceRefresh) {
15
15
  return JSON.parse(cachedData);
16
16
  }
17
17
  if (!settingsPromise) {
@@ -70,7 +70,7 @@ export default function CustomerPaymentList({ customer_id }) {
70
70
  ] }) }),
71
71
  /* @__PURE__ */ jsx(Box, { flex: 3, children: /* @__PURE__ */ jsx(Status, { label: item.status, color: getPaymentIntentStatusColor(item.status) }) }),
72
72
  /* @__PURE__ */ jsx(Box, { flex: 3, children: /* @__PURE__ */ jsx(Typography, { children: item.description || "-" }) }),
73
- /* @__PURE__ */ jsx(Box, { flex: 3, sx: { minWidth: "220px" }, children: (item.payment_details?.arcblock?.tx_hash || item.payment_details?.ethereum?.tx_hash) && /* @__PURE__ */ jsx(TxLink, { details: item.payment_details, method: item.paymentMethod, mode: "customer" }) })
73
+ /* @__PURE__ */ jsx(Box, { flex: 3, sx: { minWidth: "220px" }, children: (item.payment_details?.arcblock?.tx_hash || item.payment_details?.ethereum?.tx_hash || item.payment_details?.base?.tx_hash) && /* @__PURE__ */ jsx(TxLink, { details: item.payment_details, method: item.paymentMethod, mode: "customer" }) })
74
74
  ]
75
75
  },
76
76
  item.id
package/es/libs/util.js CHANGED
@@ -702,6 +702,13 @@ export const getTxLink = (method, details) => {
702
702
  gas: new BN(details.ethereum.gas_price).mul(new BN(details.ethereum.gas_used)).toString()
703
703
  };
704
704
  }
705
+ if (method.type === "base" && details.base?.tx_hash) {
706
+ return {
707
+ link: joinURL(method.settings.base?.explorer_host, "/tx", details.base?.tx_hash),
708
+ text: (details.base?.tx_hash).toUpperCase(),
709
+ gas: ""
710
+ };
711
+ }
705
712
  if (method.type === "stripe") {
706
713
  const dashboard = method.livemode ? "https://dashboard.stripe.com" : "https://dashboard.stripe.com/test";
707
714
  return {
@@ -855,7 +862,7 @@ export function getCustomerAvatar(did, updated_at, imageSize = 48) {
855
862
  return `/.well-known/service/user/avatar/${did}?imageFilter=resize&w=${imageSize}&h=${imageSize}&updateAt=${updated || dayjs().unix()}`;
856
863
  }
857
864
  export function hasDelegateTxHash(details, paymentMethod) {
858
- return paymentMethod?.type && ["arcblock", "ethereum"].includes(paymentMethod?.type) && // @ts-ignore
865
+ return paymentMethod?.type && ["arcblock", "ethereum", "base"].includes(paymentMethod?.type) && // @ts-ignore
859
866
  details?.[paymentMethod?.type]?.tx_hash;
860
867
  }
861
868
  export function getInvoiceDescriptionAndReason(invoice, locale = "en") {
package/es/locales/en.js CHANGED
@@ -317,8 +317,8 @@ export default flat({
317
317
  stakeForChangePayment: "Subscription payment method update",
318
318
  recharge: "Add funds",
319
319
  rechargeForSubscription: "Add funds for subscription",
320
- overdraftProtection: "SubGuard Fee",
321
- stakeForSubscriptionOverdraftProtection: "SubGuard",
320
+ overdraftProtection: "SubGuard\u2122 Fee",
321
+ stakeForSubscriptionOverdraftProtection: "SubGuard\u2122",
322
322
  gas: "Gas",
323
323
  fee: "Fee"
324
324
  }
@@ -226,7 +226,7 @@ export default function PaymentForm({
226
226
  submitting: false,
227
227
  customerLimited: false
228
228
  });
229
- if (["arcblock", "ethereum"].includes(method.type)) {
229
+ if (["arcblock", "ethereum", "base"].includes(method.type)) {
230
230
  setState({ paying: true });
231
231
  if (result.data.balance?.sufficient || result.data.delegation?.sufficient) {
232
232
  await handleConnected();
@@ -93,7 +93,7 @@ function OverdueInvoicePayment({
93
93
  }
94
94
  setSelectCurrencyId(currency.id);
95
95
  setPayLoading(true);
96
- if (method.type === "arcblock" || method.type === "ethereum") {
96
+ if (["arcblock", "ethereum", "base"].includes(method.type)) {
97
97
  connect.open({
98
98
  containerEl: void 0,
99
99
  saveConnect: false,
@@ -12,7 +12,7 @@ export type PaymentContextType = {
12
12
  connect: import('@arcblock/did-connect/lib/types').SessionContext['connectApi'];
13
13
  prefix: string;
14
14
  settings: Settings;
15
- refresh: () => void;
15
+ refresh: (forceRefresh?: boolean) => void;
16
16
  getCurrency: (currencyId: string) => TPaymentCurrency | undefined;
17
17
  getMethod: (methodId: string) => TPaymentMethodExpanded | undefined;
18
18
  setLivemode: (livemode: boolean) => void;
@@ -23,11 +23,11 @@ const {
23
23
  } = PaymentContext;
24
24
  exports.SettingsConsumer = Consumer;
25
25
  let settingsPromise = null;
26
- const getSettings = () => {
26
+ const getSettings = (forceRefresh = false) => {
27
27
  const livemode = localStorage.getItem("livemode") !== "false";
28
28
  const cacheKey = `payment-settings-${window.location.pathname}-${livemode}`;
29
29
  const cachedData = sessionStorage.getItem(cacheKey);
30
- if (cachedData) {
30
+ if (cachedData && !forceRefresh) {
31
31
  return JSON.parse(cachedData);
32
32
  }
33
33
  if (!settingsPromise) {
@@ -120,7 +120,7 @@ function CustomerPaymentList({
120
120
  sx: {
121
121
  minWidth: "220px"
122
122
  },
123
- children: (item.payment_details?.arcblock?.tx_hash || item.payment_details?.ethereum?.tx_hash) && /* @__PURE__ */(0, _jsxRuntime.jsx)(_tx.default, {
123
+ children: (item.payment_details?.arcblock?.tx_hash || item.payment_details?.ethereum?.tx_hash || item.payment_details?.base?.tx_hash) && /* @__PURE__ */(0, _jsxRuntime.jsx)(_tx.default, {
124
124
  details: item.payment_details,
125
125
  method: item.paymentMethod,
126
126
  mode: "customer"
package/lib/libs/util.js CHANGED
@@ -870,6 +870,13 @@ const getTxLink = (method, details) => {
870
870
  gas: new _util.BN(details.ethereum.gas_price).mul(new _util.BN(details.ethereum.gas_used)).toString()
871
871
  };
872
872
  }
873
+ if (method.type === "base" && details.base?.tx_hash) {
874
+ return {
875
+ link: (0, _ufo.joinURL)(method.settings.base?.explorer_host, "/tx", details.base?.tx_hash),
876
+ text: (details.base?.tx_hash).toUpperCase(),
877
+ gas: ""
878
+ };
879
+ }
873
880
  if (method.type === "stripe") {
874
881
  const dashboard = method.livemode ? "https://dashboard.stripe.com" : "https://dashboard.stripe.com/test";
875
882
  return {
@@ -1038,7 +1045,7 @@ function getCustomerAvatar(did, updated_at, imageSize = 48) {
1038
1045
  return `/.well-known/service/user/avatar/${did}?imageFilter=resize&w=${imageSize}&h=${imageSize}&updateAt=${updated || (0, _dayjs.default)().unix()}`;
1039
1046
  }
1040
1047
  function hasDelegateTxHash(details, paymentMethod) {
1041
- return paymentMethod?.type && ["arcblock", "ethereum"].includes(paymentMethod?.type) &&
1048
+ return paymentMethod?.type && ["arcblock", "ethereum", "base"].includes(paymentMethod?.type) &&
1042
1049
  // @ts-ignore
1043
1050
  details?.[paymentMethod?.type]?.tx_hash;
1044
1051
  }
package/lib/locales/en.js CHANGED
@@ -324,8 +324,8 @@ module.exports = (0, _flat.default)({
324
324
  stakeForChangePayment: "Subscription payment method update",
325
325
  recharge: "Add funds",
326
326
  rechargeForSubscription: "Add funds for subscription",
327
- overdraftProtection: "SubGuard Fee",
328
- stakeForSubscriptionOverdraftProtection: "SubGuard",
327
+ overdraftProtection: "SubGuard\u2122 Fee",
328
+ stakeForSubscriptionOverdraftProtection: "SubGuard\u2122",
329
329
  gas: "Gas",
330
330
  fee: "Fee"
331
331
  }
@@ -258,7 +258,7 @@ function PaymentForm({
258
258
  submitting: false,
259
259
  customerLimited: false
260
260
  });
261
- if (["arcblock", "ethereum"].includes(method.type)) {
261
+ if (["arcblock", "ethereum", "base"].includes(method.type)) {
262
262
  setState({
263
263
  paying: true
264
264
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/payment-react",
3
- "version": "1.17.3",
3
+ "version": "1.17.5",
4
4
  "description": "Reusable react components for payment kit v2",
5
5
  "keywords": [
6
6
  "react",
@@ -53,15 +53,15 @@
53
53
  }
54
54
  },
55
55
  "dependencies": {
56
- "@arcblock/did-connect": "^2.11.15",
57
- "@arcblock/ux": "^2.11.15",
58
- "@arcblock/ws": "^1.18.166",
59
- "@blocklet/ui-react": "^2.11.15",
56
+ "@arcblock/did-connect": "^2.11.27",
57
+ "@arcblock/ux": "^2.11.27",
58
+ "@arcblock/ws": "^1.19.3",
59
+ "@blocklet/ui-react": "^2.11.27",
60
60
  "@mui/icons-material": "^5.16.6",
61
61
  "@mui/lab": "^5.0.0-alpha.173",
62
62
  "@mui/material": "^5.16.6",
63
63
  "@mui/system": "^5.16.6",
64
- "@ocap/util": "^1.18.166",
64
+ "@ocap/util": "^1.19.3",
65
65
  "@stripe/react-stripe-js": "^2.7.3",
66
66
  "@stripe/stripe-js": "^2.4.0",
67
67
  "@vitejs/plugin-legacy": "^5.4.1",
@@ -92,7 +92,7 @@
92
92
  "@babel/core": "^7.25.2",
93
93
  "@babel/preset-env": "^7.25.2",
94
94
  "@babel/preset-react": "^7.24.7",
95
- "@blocklet/payment-types": "1.17.3",
95
+ "@blocklet/payment-types": "1.17.5",
96
96
  "@storybook/addon-essentials": "^7.6.20",
97
97
  "@storybook/addon-interactions": "^7.6.20",
98
98
  "@storybook/addon-links": "^7.6.20",
@@ -123,5 +123,5 @@
123
123
  "vite-plugin-babel": "^1.2.0",
124
124
  "vite-plugin-node-polyfills": "^0.21.0"
125
125
  },
126
- "gitHead": "bc8adef7ff5a032048eef64dc1753bcee88acb98"
126
+ "gitHead": "7713be8272f1056796820a9d52f742ed63899900"
127
127
  }
@@ -114,7 +114,7 @@ function OverdueInvoicePayment({
114
114
  }
115
115
  setSelectCurrencyId(currency.id);
116
116
  setPayLoading(true);
117
- if (method.type === 'arcblock' || method.type === 'ethereum') {
117
+ if (['arcblock', 'ethereum', 'base'].includes(method.type)) {
118
118
  connect.open({
119
119
  containerEl: undefined as unknown as Element,
120
120
  saveConnect: false,
@@ -18,7 +18,7 @@ export type PaymentContextType = {
18
18
  connect: import('@arcblock/did-connect/lib/types').SessionContext['connectApi'];
19
19
  prefix: string;
20
20
  settings: Settings;
21
- refresh: () => void;
21
+ refresh: (forceRefresh?: boolean) => void;
22
22
  getCurrency: (currencyId: string) => TPaymentCurrency | undefined;
23
23
  getMethod: (methodId: string) => TPaymentMethodExpanded | undefined;
24
24
  setLivemode: (livemode: boolean) => void;
@@ -40,11 +40,11 @@ const PaymentContext = createContext<PaymentContextType>({ api });
40
40
  const { Provider, Consumer } = PaymentContext;
41
41
 
42
42
  let settingsPromise: Promise<any> | null = null;
43
- const getSettings = () => {
43
+ const getSettings = (forceRefresh = false) => {
44
44
  const livemode = localStorage.getItem('livemode') !== 'false';
45
45
  const cacheKey = `payment-settings-${window.location.pathname}-${livemode}`;
46
46
  const cachedData = sessionStorage.getItem(cacheKey);
47
- if (cachedData) {
47
+ if (cachedData && !forceRefresh) {
48
48
  return JSON.parse(cachedData);
49
49
  }
50
50
  if (!settingsPromise) {
@@ -95,7 +95,9 @@ export default function CustomerPaymentList({ customer_id }: Props) {
95
95
  <Typography>{item.description || '-'}</Typography>
96
96
  </Box>
97
97
  <Box flex={3} sx={{ minWidth: '220px' }}>
98
- {(item.payment_details?.arcblock?.tx_hash || item.payment_details?.ethereum?.tx_hash) && (
98
+ {(item.payment_details?.arcblock?.tx_hash ||
99
+ item.payment_details?.ethereum?.tx_hash ||
100
+ item.payment_details?.base?.tx_hash) && (
99
101
  <TxLink details={item.payment_details} method={item.paymentMethod} mode="customer" />
100
102
  )}
101
103
  </Box>
package/src/libs/util.ts CHANGED
@@ -923,6 +923,13 @@ export const getTxLink = (method: TPaymentMethod, details: PaymentDetails) => {
923
923
  gas: new BN(details.ethereum.gas_price).mul(new BN(details.ethereum.gas_used)).toString(),
924
924
  };
925
925
  }
926
+ if (method.type === 'base' && details.base?.tx_hash) {
927
+ return {
928
+ link: joinURL(method.settings.base?.explorer_host as string, '/tx', details.base?.tx_hash as string),
929
+ text: (details.base?.tx_hash as string).toUpperCase(),
930
+ gas: '',
931
+ };
932
+ }
926
933
  if (method.type === 'stripe') {
927
934
  const dashboard = method.livemode ? 'https://dashboard.stripe.com' : 'https://dashboard.stripe.com/test';
928
935
  return {
@@ -1109,7 +1116,7 @@ export function getCustomerAvatar(
1109
1116
  export function hasDelegateTxHash(details: PaymentDetails, paymentMethod: TPaymentMethod) {
1110
1117
  return (
1111
1118
  paymentMethod?.type &&
1112
- ['arcblock', 'ethereum'].includes(paymentMethod?.type) &&
1119
+ ['arcblock', 'ethereum', 'base'].includes(paymentMethod?.type) &&
1113
1120
  // @ts-ignore
1114
1121
  details?.[paymentMethod?.type]?.tx_hash
1115
1122
  );
@@ -330,8 +330,8 @@ export default flat({
330
330
  stakeForChangePayment: 'Subscription payment method update',
331
331
  recharge: 'Add funds',
332
332
  rechargeForSubscription: 'Add funds for subscription',
333
- overdraftProtection: 'SubGuard Fee',
334
- stakeForSubscriptionOverdraftProtection: 'SubGuard',
333
+ overdraftProtection: 'SubGuard Fee',
334
+ stakeForSubscriptionOverdraftProtection: 'SubGuard',
335
335
  gas: 'Gas',
336
336
  fee: 'Fee',
337
337
  },
@@ -300,7 +300,7 @@ export default function PaymentForm({
300
300
  customerLimited: false,
301
301
  });
302
302
 
303
- if (['arcblock', 'ethereum'].includes(method.type)) {
303
+ if (['arcblock', 'ethereum', 'base'].includes(method.type)) {
304
304
  setState({ paying: true });
305
305
  if (result.data.balance?.sufficient || result.data.delegation?.sufficient) {
306
306
  await handleConnected();