@blocklet/payment-react 1.13.229 → 1.13.230
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.
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { PaymentDetails,
|
|
2
|
+
import type { PaymentDetails, TPaymentMethod } from '@blocklet/payment-types';
|
|
3
3
|
declare function TxGas(props: {
|
|
4
4
|
details: PaymentDetails;
|
|
5
|
-
currency: TPaymentCurrency;
|
|
6
5
|
method: TPaymentMethod;
|
|
7
6
|
}): import("react").JSX.Element;
|
|
8
7
|
declare namespace TxGas {
|
|
@@ -2,18 +2,22 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
3
3
|
import { Typography } from "@mui/material";
|
|
4
4
|
import { fromUnitToToken } from "@ocap/util";
|
|
5
|
+
import { usePaymentContext } from "../../contexts/payment.js";
|
|
5
6
|
import { getTxLink } from "../../util.js";
|
|
6
7
|
TxGas.defaultProps = {};
|
|
7
8
|
export default function TxGas(props) {
|
|
8
9
|
const { t } = useLocaleContext();
|
|
10
|
+
const { settings } = usePaymentContext();
|
|
9
11
|
const { gas } = getTxLink(props.method, props.details);
|
|
10
|
-
|
|
12
|
+
const method = settings.paymentMethods.find((x) => x.id === props.method.id);
|
|
13
|
+
if (gas && method) {
|
|
14
|
+
const currency = method.payment_currencies.find((x) => x.id === method.default_currency_id);
|
|
11
15
|
return /* @__PURE__ */ jsxs(Typography, { component: "span", children: [
|
|
12
|
-
fromUnitToToken(gas,
|
|
16
|
+
fromUnitToToken(gas, currency.decimal),
|
|
13
17
|
" ",
|
|
14
|
-
|
|
18
|
+
currency.symbol,
|
|
15
19
|
" (",
|
|
16
|
-
|
|
20
|
+
method.name,
|
|
17
21
|
")"
|
|
18
22
|
] });
|
|
19
23
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { PaymentDetails,
|
|
2
|
+
import type { PaymentDetails, TPaymentMethod } from '@blocklet/payment-types';
|
|
3
3
|
declare function TxGas(props: {
|
|
4
4
|
details: PaymentDetails;
|
|
5
|
-
currency: TPaymentCurrency;
|
|
6
5
|
method: TPaymentMethod;
|
|
7
6
|
}): import("react").JSX.Element;
|
|
8
7
|
declare namespace TxGas {
|
|
@@ -8,19 +8,25 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
8
8
|
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
9
9
|
var _material = require("@mui/material");
|
|
10
10
|
var _util = require("@ocap/util");
|
|
11
|
+
var _payment = require("../../contexts/payment");
|
|
11
12
|
var _util2 = require("../../util");
|
|
12
13
|
TxGas.defaultProps = {};
|
|
13
14
|
function TxGas(props) {
|
|
14
15
|
const {
|
|
15
16
|
t
|
|
16
17
|
} = (0, _context.useLocaleContext)();
|
|
18
|
+
const {
|
|
19
|
+
settings
|
|
20
|
+
} = (0, _payment.usePaymentContext)();
|
|
17
21
|
const {
|
|
18
22
|
gas
|
|
19
23
|
} = (0, _util2.getTxLink)(props.method, props.details);
|
|
20
|
-
|
|
24
|
+
const method = settings.paymentMethods.find(x => x.id === props.method.id);
|
|
25
|
+
if (gas && method) {
|
|
26
|
+
const currency = method.payment_currencies.find(x => x.id === method.default_currency_id);
|
|
21
27
|
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
22
28
|
component: "span",
|
|
23
|
-
children: [(0, _util.fromUnitToToken)(gas,
|
|
29
|
+
children: [(0, _util.fromUnitToToken)(gas, currency.decimal), " ", currency.symbol, " (", method.name, ")"]
|
|
24
30
|
});
|
|
25
31
|
}
|
|
26
32
|
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/payment-react",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.230",
|
|
4
4
|
"description": "Reusable react components for payment kit v2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"@babel/core": "^7.24.4",
|
|
91
91
|
"@babel/preset-env": "^7.24.4",
|
|
92
92
|
"@babel/preset-react": "^7.24.1",
|
|
93
|
-
"@blocklet/payment-types": "1.13.
|
|
93
|
+
"@blocklet/payment-types": "1.13.230",
|
|
94
94
|
"@storybook/addon-essentials": "^7.6.17",
|
|
95
95
|
"@storybook/addon-interactions": "^7.6.17",
|
|
96
96
|
"@storybook/addon-links": "^7.6.17",
|
|
@@ -119,5 +119,5 @@
|
|
|
119
119
|
"vite-plugin-babel": "^1.2.0",
|
|
120
120
|
"vite-plugin-node-polyfills": "^0.21.0"
|
|
121
121
|
},
|
|
122
|
-
"gitHead": "
|
|
122
|
+
"gitHead": "c7209ae95049960f39b4e9eb65714626fb56ceab"
|
|
123
123
|
}
|
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
2
|
-
import type { PaymentDetails,
|
|
2
|
+
import type { PaymentDetails, TPaymentMethod } from '@blocklet/payment-types';
|
|
3
3
|
import { Typography } from '@mui/material';
|
|
4
4
|
import { fromUnitToToken } from '@ocap/util';
|
|
5
5
|
|
|
6
|
+
import { usePaymentContext } from '../../contexts/payment';
|
|
6
7
|
import { getTxLink } from '../../util';
|
|
7
8
|
|
|
8
9
|
TxGas.defaultProps = {};
|
|
9
10
|
|
|
10
|
-
export default function TxGas(props: { details: PaymentDetails;
|
|
11
|
+
export default function TxGas(props: { details: PaymentDetails; method: TPaymentMethod }) {
|
|
11
12
|
const { t } = useLocaleContext();
|
|
13
|
+
const { settings } = usePaymentContext();
|
|
12
14
|
|
|
13
15
|
const { gas } = getTxLink(props.method, props.details);
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
const method = settings.paymentMethods.find((x) => x.id === props.method.id);
|
|
18
|
+
if (gas && method) {
|
|
19
|
+
const currency = method.payment_currencies.find((x) => x.id === method.default_currency_id);
|
|
16
20
|
return (
|
|
17
21
|
<Typography component="span">
|
|
18
|
-
{fromUnitToToken(gas,
|
|
22
|
+
{fromUnitToToken(gas, currency!.decimal)} {currency!.symbol} ({method.name})
|
|
19
23
|
</Typography>
|
|
20
24
|
);
|
|
21
25
|
}
|