@arcblock/ux 2.9.60 → 2.9.62
Sign up to get free protection for your applications and to get access to all the features.
- package/es/Avatar/index.js +3 -2
- package/es/DID/index.js +55 -19
- package/es/Util/constant.js +1 -0
- package/es/Util/index.js +2 -1
- package/lib/Avatar/index.js +3 -2
- package/lib/DID/index.js +54 -17
- package/lib/Util/constant.js +2 -1
- package/lib/Util/index.js +2 -1
- package/package.json +5 -5
- package/src/Avatar/index.jsx +3 -2
- package/src/DID/index.jsx +59 -12
- package/src/Util/constant.js +2 -0
- package/src/Util/index.js +2 -1
package/es/Avatar/index.js
CHANGED
@@ -8,6 +8,7 @@ import Img from '../Img';
|
|
8
8
|
import { mergeProps, isEthereumDid } from '../Util';
|
9
9
|
import DIDMotif from './did-motif';
|
10
10
|
import blockies from './etherscan-blockies';
|
11
|
+
import { DID_PREFIX } from '../Util/constant';
|
11
12
|
|
12
13
|
/**
|
13
14
|
* Avatar component
|
@@ -48,7 +49,7 @@ function Avatar(props) {
|
|
48
49
|
const blockyIcon = useMemo(() => {
|
49
50
|
if (isEthereumDid(did)) {
|
50
51
|
return blockies.createIcon({
|
51
|
-
seed: did.replace(
|
52
|
+
seed: did.replace(DID_PREFIX, '').toLowerCase(),
|
52
53
|
size: 8,
|
53
54
|
scale: 16
|
54
55
|
}).toDataURL();
|
@@ -126,7 +127,7 @@ function Avatar(props) {
|
|
126
127
|
if (did) {
|
127
128
|
// 渲染 did motif
|
128
129
|
return /*#__PURE__*/_jsx(DIDMotif, {
|
129
|
-
did: did.replace(
|
130
|
+
did: did.replace(DID_PREFIX, ''),
|
130
131
|
size: size,
|
131
132
|
animation: animation,
|
132
133
|
shape: Shape[(shape || '').toUpperCase()],
|
package/es/DID/index.js
CHANGED
@@ -4,20 +4,27 @@ import { getDIDMotifInfo } from '@arcblock/did-motif';
|
|
4
4
|
import QRCode from 'qrcode.react';
|
5
5
|
import { Icon } from '@iconify/react';
|
6
6
|
import IconQrCode from '@iconify-icons/material-symbols/qr-code-rounded';
|
7
|
-
import { Box, Dialog, DialogContent, DialogTitle } from '@mui/material';
|
8
|
-
import { useMemoizedFn } from 'ahooks';
|
7
|
+
import { Box, Dialog, DialogContent, DialogTitle, Typography } from '@mui/material';
|
8
|
+
import { useCreation, useMemoizedFn } from 'ahooks';
|
9
|
+
import { temp as colors } from '../Colors';
|
10
|
+
import { DID_PREFIX } from '../Util/constant';
|
9
11
|
import Address from '../Address';
|
10
12
|
import Avatar from '../Avatar';
|
11
13
|
import { isEthereumDid, getFontSize, getDIDColor } from '../Util';
|
14
|
+
import { translate } from '../Locale/util';
|
12
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
13
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
14
16
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
17
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
15
18
|
const translations = {
|
16
19
|
en: {
|
17
|
-
scanQrcode: 'Scan with DID Wallet to transfer token to here'
|
20
|
+
scanQrcode: 'Scan with DID Wallet to transfer token to here',
|
21
|
+
download: 'Download',
|
22
|
+
downloadTips: "Don't have DID Wallet ?"
|
18
23
|
},
|
19
24
|
zh: {
|
20
|
-
scanQrcode: '扫描此二维码,用 DID
|
25
|
+
scanQrcode: '扫描此二维码,用 DID Wallet 转账',
|
26
|
+
download: '下载',
|
27
|
+
downloadTips: '没有 DID Wallet ?'
|
21
28
|
}
|
22
29
|
};
|
23
30
|
const DIDPropTypes = {
|
@@ -79,10 +86,9 @@ const DID = /*#__PURE__*/forwardRef(({
|
|
79
86
|
locale,
|
80
87
|
...rest
|
81
88
|
}, ref) => {
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
}
|
89
|
+
const t = useMemoizedFn((key, data = {}) => {
|
90
|
+
return translate(translations, key, locale, 'en', data);
|
91
|
+
});
|
86
92
|
try {
|
87
93
|
if (!chainId) {
|
88
94
|
const chainHostUrl = window?.blocklet?.CHAIN_HOST;
|
@@ -132,10 +138,35 @@ const DID = /*#__PURE__*/forwardRef(({
|
|
132
138
|
const openQrCode = useMemoizedFn(() => {
|
133
139
|
setOpen(true);
|
134
140
|
});
|
141
|
+
const downloadUrl = useCreation(() => {
|
142
|
+
if (['zh', 'en'].includes) {
|
143
|
+
return `https://www.didwallet.io/${locale}`;
|
144
|
+
}
|
145
|
+
return 'https://www.didwallet.io/en';
|
146
|
+
}, [locale]);
|
147
|
+
const downloadTips = useCreation(() => {
|
148
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
149
|
+
children: [t('downloadTips'), ' ', /*#__PURE__*/_jsx(Box, {
|
150
|
+
component: "a",
|
151
|
+
href: downloadUrl,
|
152
|
+
target: "_blank",
|
153
|
+
rel: "noreferrer",
|
154
|
+
sx: {
|
155
|
+
color: colors.foregroundsFgInteractive,
|
156
|
+
textDecoration: 'none',
|
157
|
+
'&:hover': {
|
158
|
+
textDecoration: 'underline'
|
159
|
+
}
|
160
|
+
},
|
161
|
+
children: t('download')
|
162
|
+
})]
|
163
|
+
});
|
164
|
+
}, [downloadUrl]);
|
135
165
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
136
166
|
children: [/*#__PURE__*/_jsx(Address, {
|
137
167
|
ref: ref,
|
138
168
|
locale: locale,
|
169
|
+
content: `${DID_PREFIX}${did}`,
|
139
170
|
...rest,
|
140
171
|
prepend: prepend,
|
141
172
|
append: showQrcode ? /*#__PURE__*/_jsx(Box, {
|
@@ -155,22 +186,17 @@ const DID = /*#__PURE__*/forwardRef(({
|
|
155
186
|
maxWidth: "sm",
|
156
187
|
children: [/*#__PURE__*/_jsx(DialogTitle, {
|
157
188
|
align: "center",
|
158
|
-
children: /*#__PURE__*/_jsx(
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
xs: 13,
|
163
|
-
sm: 'inherit'
|
164
|
-
},
|
165
|
-
component: "span",
|
166
|
-
children: translations[locale].scanQrcode
|
189
|
+
children: /*#__PURE__*/_jsx(Typography, {
|
190
|
+
variant: "h6",
|
191
|
+
component: "h3",
|
192
|
+
children: t('scanQrcode')
|
167
193
|
})
|
168
194
|
}), /*#__PURE__*/_jsxs(DialogContent, {
|
169
195
|
align: "center",
|
170
196
|
children: [/*#__PURE__*/_jsx(QRCode
|
171
197
|
// eslint-disable-next-line max-len
|
172
198
|
, {
|
173
|
-
value: `abt://abtwallet.io/i?did
|
199
|
+
value: `abt://abtwallet.io/i?did=${DID_PREFIX}${did}&action=didRecognize&chainID=${chainId || DEFAULT_CHAIN_ID}`,
|
174
200
|
size: 256,
|
175
201
|
renderAs: "svg",
|
176
202
|
level: "M"
|
@@ -182,8 +208,18 @@ const DID = /*#__PURE__*/forwardRef(({
|
|
182
208
|
children: /*#__PURE__*/_jsx(Address, {
|
183
209
|
copyable: true,
|
184
210
|
locale: locale,
|
211
|
+
content: `${DID_PREFIX}${did}`,
|
212
|
+
prepend: prepend,
|
185
213
|
children: did
|
186
214
|
})
|
215
|
+
}), /*#__PURE__*/_jsx(Typography, {
|
216
|
+
variant: "body2",
|
217
|
+
sx: {
|
218
|
+
color: colors.textSubtitle,
|
219
|
+
fontSize: '12px',
|
220
|
+
mt: 1
|
221
|
+
},
|
222
|
+
children: downloadTips
|
187
223
|
})]
|
188
224
|
})]
|
189
225
|
})]
|
package/es/Util/constant.js
CHANGED
@@ -8,6 +8,7 @@ export const API_DID_PREFIX = '/api/did';
|
|
8
8
|
export const DASHBOARD_URL = `${AUTH_SERVICE_PREFIX}/admin`;
|
9
9
|
export const PROFILE_URL = `${AUTH_SERVICE_PREFIX}/user`;
|
10
10
|
export const NAVIGATION_URL = `${AUTH_SERVICE_PREFIX}/admin/navigation`;
|
11
|
+
export const DID_PREFIX = 'did:abt:';
|
11
12
|
export const PASSPORT_STATUS = {
|
12
13
|
VALID: 'valid',
|
13
14
|
REVOKED: 'revoked'
|
package/es/Util/index.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
/* eslint-disable no-bitwise */
|
2
2
|
import padStart from 'lodash/padStart';
|
3
3
|
import { getDIDMotifInfo, colors } from '@arcblock/did-motif';
|
4
|
+
import { DID_PREFIX } from './constant';
|
4
5
|
let dateTool = null;
|
5
6
|
export function parseQuery(str) {
|
6
7
|
return str.replace(/^\?/, '').split('&').map(x => x.split('=')).filter(([key]) => !!key).reduce((memo, x) => {
|
@@ -251,7 +252,7 @@ export const getFontSize = size => {
|
|
251
252
|
|
252
253
|
// 参考: asset-chain @arcblock/did
|
253
254
|
export const isEthereumDid = did => {
|
254
|
-
const address = did.replace(
|
255
|
+
const address = did.replace(DID_PREFIX, '');
|
255
256
|
// check if it has the basic requirements of an address
|
256
257
|
if (!/^(0x)?[0-9a-f]{40}$/i.test(address)) {
|
257
258
|
return false;
|
package/lib/Avatar/index.js
CHANGED
@@ -13,6 +13,7 @@ var _Img = _interopRequireDefault(require("../Img"));
|
|
13
13
|
var _Util = require("../Util");
|
14
14
|
var _didMotif2 = _interopRequireDefault(require("./did-motif"));
|
15
15
|
var _etherscanBlockies = _interopRequireDefault(require("./etherscan-blockies"));
|
16
|
+
var _constant = require("../Util/constant");
|
16
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
17
18
|
const _excluded = ["did", "size", "src", "variant", "animation", "shape", "blockiesPadding", "responsive"];
|
18
19
|
/* eslint-disable react/no-unused-prop-types */
|
@@ -61,7 +62,7 @@ function Avatar(props) {
|
|
61
62
|
const blockyIcon = (0, _react.useMemo)(() => {
|
62
63
|
if ((0, _Util.isEthereumDid)(did)) {
|
63
64
|
return _etherscanBlockies.default.createIcon({
|
64
|
-
seed: did.replace(
|
65
|
+
seed: did.replace(_constant.DID_PREFIX, '').toLowerCase(),
|
65
66
|
size: 8,
|
66
67
|
scale: 16
|
67
68
|
}).toDataURL();
|
@@ -135,7 +136,7 @@ function Avatar(props) {
|
|
135
136
|
if (did) {
|
136
137
|
// 渲染 did motif
|
137
138
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_didMotif2.default, _objectSpread({
|
138
|
-
did: did.replace(
|
139
|
+
did: did.replace(_constant.DID_PREFIX, ''),
|
139
140
|
size: size,
|
140
141
|
animation: animation,
|
141
142
|
shape: _didMotif.Shape[(shape || '').toUpperCase()],
|
package/lib/DID/index.js
CHANGED
@@ -12,9 +12,12 @@ var _react2 = require("@iconify/react");
|
|
12
12
|
var _qrCodeRounded = _interopRequireDefault(require("@iconify-icons/material-symbols/qr-code-rounded"));
|
13
13
|
var _material = require("@mui/material");
|
14
14
|
var _ahooks = require("ahooks");
|
15
|
+
var _Colors = require("../Colors");
|
16
|
+
var _constant = require("../Util/constant");
|
15
17
|
var _Address = _interopRequireDefault(require("../Address"));
|
16
18
|
var _Avatar = _interopRequireDefault(require("../Avatar"));
|
17
19
|
var _Util = require("../Util");
|
20
|
+
var _util = require("../Locale/util");
|
18
21
|
var _jsxRuntime = require("react/jsx-runtime");
|
19
22
|
const _excluded = ["did", "showAvatar", "showQrcode", "chainId", "locale"];
|
20
23
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
@@ -27,10 +30,14 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
27
30
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
28
31
|
const translations = {
|
29
32
|
en: {
|
30
|
-
scanQrcode: 'Scan with DID Wallet to transfer token to here'
|
33
|
+
scanQrcode: 'Scan with DID Wallet to transfer token to here',
|
34
|
+
download: 'Download',
|
35
|
+
downloadTips: "Don't have DID Wallet ?"
|
31
36
|
},
|
32
37
|
zh: {
|
33
|
-
scanQrcode: '扫描此二维码,用 DID
|
38
|
+
scanQrcode: '扫描此二维码,用 DID Wallet 转账',
|
39
|
+
download: '下载',
|
40
|
+
downloadTips: '没有 DID Wallet ?'
|
34
41
|
}
|
35
42
|
};
|
36
43
|
const DIDPropTypes = {
|
@@ -93,10 +100,10 @@ const DID = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
93
100
|
locale
|
94
101
|
} = _ref,
|
95
102
|
rest = _objectWithoutProperties(_ref, _excluded);
|
96
|
-
|
97
|
-
|
98
|
-
locale
|
99
|
-
}
|
103
|
+
const t = (0, _ahooks.useMemoizedFn)(function (key) {
|
104
|
+
let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
105
|
+
return (0, _util.translate)(translations, key, locale, 'en', data);
|
106
|
+
});
|
100
107
|
try {
|
101
108
|
if (!chainId) {
|
102
109
|
var _window, _window$blocklet;
|
@@ -147,10 +154,35 @@ const DID = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
147
154
|
const openQrCode = (0, _ahooks.useMemoizedFn)(() => {
|
148
155
|
setOpen(true);
|
149
156
|
});
|
157
|
+
const downloadUrl = (0, _ahooks.useCreation)(() => {
|
158
|
+
if (['zh', 'en'].includes) {
|
159
|
+
return "https://www.didwallet.io/".concat(locale);
|
160
|
+
}
|
161
|
+
return 'https://www.didwallet.io/en';
|
162
|
+
}, [locale]);
|
163
|
+
const downloadTips = (0, _ahooks.useCreation)(() => {
|
164
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
165
|
+
children: [t('downloadTips'), ' ', /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
|
166
|
+
component: "a",
|
167
|
+
href: downloadUrl,
|
168
|
+
target: "_blank",
|
169
|
+
rel: "noreferrer",
|
170
|
+
sx: {
|
171
|
+
color: _Colors.temp.foregroundsFgInteractive,
|
172
|
+
textDecoration: 'none',
|
173
|
+
'&:hover': {
|
174
|
+
textDecoration: 'underline'
|
175
|
+
}
|
176
|
+
},
|
177
|
+
children: t('download')
|
178
|
+
})]
|
179
|
+
});
|
180
|
+
}, [downloadUrl]);
|
150
181
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
151
182
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Address.default, _objectSpread(_objectSpread({
|
152
183
|
ref: ref,
|
153
|
-
locale: locale
|
184
|
+
locale: locale,
|
185
|
+
content: "".concat(_constant.DID_PREFIX).concat(did)
|
154
186
|
}, rest), {}, {
|
155
187
|
prepend: prepend,
|
156
188
|
append: showQrcode ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
|
@@ -170,22 +202,17 @@ const DID = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
170
202
|
maxWidth: "sm",
|
171
203
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.DialogTitle, {
|
172
204
|
align: "center",
|
173
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
xs: 13,
|
178
|
-
sm: 'inherit'
|
179
|
-
},
|
180
|
-
component: "span",
|
181
|
-
children: translations[locale].scanQrcode
|
205
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
206
|
+
variant: "h6",
|
207
|
+
component: "h3",
|
208
|
+
children: t('scanQrcode')
|
182
209
|
})
|
183
210
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.DialogContent, {
|
184
211
|
align: "center",
|
185
212
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_qrcode.default
|
186
213
|
// eslint-disable-next-line max-len
|
187
214
|
, {
|
188
|
-
value: "abt://abtwallet.io/i?did=
|
215
|
+
value: "abt://abtwallet.io/i?did=".concat(_constant.DID_PREFIX).concat(did, "&action=didRecognize&chainID=").concat(chainId || DEFAULT_CHAIN_ID),
|
189
216
|
size: 256,
|
190
217
|
renderAs: "svg",
|
191
218
|
level: "M"
|
@@ -197,8 +224,18 @@ const DID = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
197
224
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Address.default, {
|
198
225
|
copyable: true,
|
199
226
|
locale: locale,
|
227
|
+
content: "".concat(_constant.DID_PREFIX).concat(did),
|
228
|
+
prepend: prepend,
|
200
229
|
children: did
|
201
230
|
})
|
231
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
232
|
+
variant: "body2",
|
233
|
+
sx: {
|
234
|
+
color: _Colors.temp.textSubtitle,
|
235
|
+
fontSize: '12px',
|
236
|
+
mt: 1
|
237
|
+
},
|
238
|
+
children: downloadTips
|
202
239
|
})]
|
203
240
|
})]
|
204
241
|
})]
|
package/lib/Util/constant.js
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.SESSION_TOKEN_STORAGE_KEY = exports.RELAY_SOCKET_PREFIX = exports.REFRESH_TOKEN_STORAGE_KEY = exports.PROFILE_URL = exports.PASSPORT_STATUS = exports.NAVIGATION_URL = exports.DEFAULT_WINDOW_TIMEOUT = exports.DEFAULT_TIMEOUT = exports.DASHBOARD_URL = exports.AUTH_SERVICE_PREFIX = exports.API_DID_PREFIX = void 0;
|
6
|
+
exports.SESSION_TOKEN_STORAGE_KEY = exports.RELAY_SOCKET_PREFIX = exports.REFRESH_TOKEN_STORAGE_KEY = exports.PROFILE_URL = exports.PASSPORT_STATUS = exports.NAVIGATION_URL = exports.DID_PREFIX = exports.DEFAULT_WINDOW_TIMEOUT = exports.DEFAULT_TIMEOUT = exports.DASHBOARD_URL = exports.AUTH_SERVICE_PREFIX = exports.API_DID_PREFIX = void 0;
|
7
7
|
const DEFAULT_TIMEOUT = exports.DEFAULT_TIMEOUT = 5 * 60;
|
8
8
|
const DEFAULT_WINDOW_TIMEOUT = exports.DEFAULT_WINDOW_TIMEOUT = 30 * 60;
|
9
9
|
const AUTH_SERVICE_PREFIX = exports.AUTH_SERVICE_PREFIX = '/.well-known/service';
|
@@ -14,6 +14,7 @@ const API_DID_PREFIX = exports.API_DID_PREFIX = '/api/did';
|
|
14
14
|
const DASHBOARD_URL = exports.DASHBOARD_URL = "".concat(AUTH_SERVICE_PREFIX, "/admin");
|
15
15
|
const PROFILE_URL = exports.PROFILE_URL = "".concat(AUTH_SERVICE_PREFIX, "/user");
|
16
16
|
const NAVIGATION_URL = exports.NAVIGATION_URL = "".concat(AUTH_SERVICE_PREFIX, "/admin/navigation");
|
17
|
+
const DID_PREFIX = exports.DID_PREFIX = 'did:abt:';
|
17
18
|
const PASSPORT_STATUS = exports.PASSPORT_STATUS = {
|
18
19
|
VALID: 'valid',
|
19
20
|
REVOKED: 'revoked'
|
package/lib/Util/index.js
CHANGED
@@ -21,6 +21,7 @@ exports.str2color = exports.sleep = exports.setVisitorId = void 0;
|
|
21
21
|
exports.stringifyQuery = stringifyQuery;
|
22
22
|
var _padStart = _interopRequireDefault(require("lodash/padStart"));
|
23
23
|
var _didMotif = require("@arcblock/did-motif");
|
24
|
+
var _constant = require("./constant");
|
24
25
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
25
26
|
/* eslint-disable no-bitwise */
|
26
27
|
|
@@ -292,7 +293,7 @@ const getFontSize = size => {
|
|
292
293
|
// 参考: asset-chain @arcblock/did
|
293
294
|
exports.getFontSize = getFontSize;
|
294
295
|
const isEthereumDid = did => {
|
295
|
-
const address = did.replace(
|
296
|
+
const address = did.replace(_constant.DID_PREFIX, '');
|
296
297
|
// check if it has the basic requirements of an address
|
297
298
|
if (!/^(0x)?[0-9a-f]{40}$/i.test(address)) {
|
298
299
|
return false;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@arcblock/ux",
|
3
|
-
"version": "2.9.
|
3
|
+
"version": "2.9.62",
|
4
4
|
"description": "Common used react components for arcblock products",
|
5
5
|
"keywords": [
|
6
6
|
"react",
|
@@ -358,12 +358,12 @@
|
|
358
358
|
"@mui/material": "^5.15.0",
|
359
359
|
"react": ">=18.2.0"
|
360
360
|
},
|
361
|
-
"gitHead": "
|
361
|
+
"gitHead": "0e898a48269d71e8e35a784f6c317211060cfae8",
|
362
362
|
"dependencies": {
|
363
363
|
"@arcblock/did-motif": "^1.1.13",
|
364
|
-
"@arcblock/icons": "^2.9.
|
365
|
-
"@arcblock/nft-display": "^2.9.
|
366
|
-
"@arcblock/react-hooks": "^2.9.
|
364
|
+
"@arcblock/icons": "^2.9.62",
|
365
|
+
"@arcblock/nft-display": "^2.9.62",
|
366
|
+
"@arcblock/react-hooks": "^2.9.62",
|
367
367
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
368
368
|
"@emotion/react": "^11.10.4",
|
369
369
|
"@emotion/styled": "^11.10.4",
|
package/src/Avatar/index.jsx
CHANGED
@@ -8,6 +8,7 @@ import Img from '../Img';
|
|
8
8
|
import { mergeProps, isEthereumDid } from '../Util';
|
9
9
|
import DIDMotif from './did-motif';
|
10
10
|
import blockies from './etherscan-blockies';
|
11
|
+
import { DID_PREFIX } from '../Util/constant';
|
11
12
|
|
12
13
|
/**
|
13
14
|
* Avatar component
|
@@ -38,7 +39,7 @@ function Avatar(props) {
|
|
38
39
|
if (isEthereumDid(did)) {
|
39
40
|
return blockies
|
40
41
|
.createIcon({
|
41
|
-
seed: did.replace(
|
42
|
+
seed: did.replace(DID_PREFIX, '').toLowerCase(),
|
42
43
|
size: 8,
|
43
44
|
scale: 16,
|
44
45
|
})
|
@@ -111,7 +112,7 @@ function Avatar(props) {
|
|
111
112
|
// 渲染 did motif
|
112
113
|
return (
|
113
114
|
<DIDMotif
|
114
|
-
did={did.replace(
|
115
|
+
did={did.replace(DID_PREFIX, '')}
|
115
116
|
size={size}
|
116
117
|
animation={animation}
|
117
118
|
shape={Shape[(shape || '').toUpperCase()]}
|
package/src/DID/index.jsx
CHANGED
@@ -4,20 +4,27 @@ import { getDIDMotifInfo } from '@arcblock/did-motif';
|
|
4
4
|
import QRCode from 'qrcode.react';
|
5
5
|
import { Icon } from '@iconify/react';
|
6
6
|
import IconQrCode from '@iconify-icons/material-symbols/qr-code-rounded';
|
7
|
-
import { Box, Dialog, DialogContent, DialogTitle } from '@mui/material';
|
8
|
-
import { useMemoizedFn } from 'ahooks';
|
7
|
+
import { Box, Dialog, DialogContent, DialogTitle, Typography } from '@mui/material';
|
8
|
+
import { useCreation, useMemoizedFn } from 'ahooks';
|
9
9
|
|
10
|
+
import { temp as colors } from '../Colors';
|
11
|
+
import { DID_PREFIX } from '../Util/constant';
|
10
12
|
import Address from '../Address';
|
11
13
|
import Avatar from '../Avatar';
|
12
14
|
|
13
15
|
import { isEthereumDid, getFontSize, getDIDColor } from '../Util';
|
16
|
+
import { translate } from '../Locale/util';
|
14
17
|
|
15
18
|
const translations = {
|
16
19
|
en: {
|
17
20
|
scanQrcode: 'Scan with DID Wallet to transfer token to here',
|
21
|
+
download: 'Download',
|
22
|
+
downloadTips: "Don't have DID Wallet ?",
|
18
23
|
},
|
19
24
|
zh: {
|
20
|
-
scanQrcode: '扫描此二维码,用 DID
|
25
|
+
scanQrcode: '扫描此二维码,用 DID Wallet 转账',
|
26
|
+
download: '下载',
|
27
|
+
downloadTips: '没有 DID Wallet ?',
|
21
28
|
},
|
22
29
|
};
|
23
30
|
|
@@ -77,10 +84,9 @@ const getAvatarSize = (didMotifInfo, isEthDid, size) => {
|
|
77
84
|
* @type React.ForwardRefRenderFunction<HTMLElement, typeof DIDPropTypes>
|
78
85
|
*/
|
79
86
|
const DID = forwardRef(({ did, showAvatar, showQrcode, chainId, locale, ...rest }, ref) => {
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
}
|
87
|
+
const t = useMemoizedFn((key, data = {}) => {
|
88
|
+
return translate(translations, key, locale, 'en', data);
|
89
|
+
});
|
84
90
|
|
85
91
|
try {
|
86
92
|
if (!chainId) {
|
@@ -125,11 +131,41 @@ const DID = forwardRef(({ did, showAvatar, showQrcode, chainId, locale, ...rest
|
|
125
131
|
setOpen(true);
|
126
132
|
});
|
127
133
|
|
134
|
+
const downloadUrl = useCreation(() => {
|
135
|
+
if (['zh', 'en'].includes) {
|
136
|
+
return `https://www.didwallet.io/${locale}`;
|
137
|
+
}
|
138
|
+
return 'https://www.didwallet.io/en';
|
139
|
+
}, [locale]);
|
140
|
+
|
141
|
+
const downloadTips = useCreation(() => {
|
142
|
+
return (
|
143
|
+
<>
|
144
|
+
{t('downloadTips')}{' '}
|
145
|
+
<Box
|
146
|
+
component="a"
|
147
|
+
href={downloadUrl}
|
148
|
+
target="_blank"
|
149
|
+
rel="noreferrer"
|
150
|
+
sx={{
|
151
|
+
color: colors.foregroundsFgInteractive,
|
152
|
+
textDecoration: 'none',
|
153
|
+
'&:hover': {
|
154
|
+
textDecoration: 'underline',
|
155
|
+
},
|
156
|
+
}}>
|
157
|
+
{t('download')}
|
158
|
+
</Box>
|
159
|
+
</>
|
160
|
+
);
|
161
|
+
}, [downloadUrl]);
|
162
|
+
|
128
163
|
return (
|
129
164
|
<>
|
130
165
|
<Address
|
131
166
|
ref={ref}
|
132
167
|
locale={locale}
|
168
|
+
content={`${DID_PREFIX}${did}`}
|
133
169
|
{...rest}
|
134
170
|
prepend={prepend}
|
135
171
|
append={
|
@@ -151,23 +187,34 @@ const DID = forwardRef(({ did, showAvatar, showQrcode, chainId, locale, ...rest
|
|
151
187
|
|
152
188
|
<Dialog open={open} onClose={closeQrCode} maxWidth="sm">
|
153
189
|
<DialogTitle align="center">
|
154
|
-
<
|
155
|
-
{
|
156
|
-
</
|
190
|
+
<Typography variant="h6" component="h3">
|
191
|
+
{t('scanQrcode')}
|
192
|
+
</Typography>
|
157
193
|
</DialogTitle>
|
158
194
|
<DialogContent align="center">
|
159
195
|
<QRCode
|
160
196
|
// eslint-disable-next-line max-len
|
161
|
-
value={`abt://abtwallet.io/i?did
|
197
|
+
value={`abt://abtwallet.io/i?did=${DID_PREFIX}${did}&action=didRecognize&chainID=${
|
198
|
+
chainId || DEFAULT_CHAIN_ID
|
199
|
+
}`}
|
162
200
|
size={256}
|
163
201
|
renderAs="svg"
|
164
202
|
level="M"
|
165
203
|
/>
|
166
204
|
<Box sx={{ marginTop: 1, textAlign: 'center' }}>
|
167
|
-
<Address copyable locale={locale}>
|
205
|
+
<Address copyable locale={locale} content={`${DID_PREFIX}${did}`} prepend={prepend}>
|
168
206
|
{did}
|
169
207
|
</Address>
|
170
208
|
</Box>
|
209
|
+
<Typography
|
210
|
+
variant="body2"
|
211
|
+
sx={{
|
212
|
+
color: colors.textSubtitle,
|
213
|
+
fontSize: '12px',
|
214
|
+
mt: 1,
|
215
|
+
}}>
|
216
|
+
{downloadTips}
|
217
|
+
</Typography>
|
171
218
|
</DialogContent>
|
172
219
|
</Dialog>
|
173
220
|
</>
|
package/src/Util/constant.js
CHANGED
@@ -11,6 +11,8 @@ export const DASHBOARD_URL = `${AUTH_SERVICE_PREFIX}/admin`;
|
|
11
11
|
export const PROFILE_URL = `${AUTH_SERVICE_PREFIX}/user`;
|
12
12
|
export const NAVIGATION_URL = `${AUTH_SERVICE_PREFIX}/admin/navigation`;
|
13
13
|
|
14
|
+
export const DID_PREFIX = 'did:abt:';
|
15
|
+
|
14
16
|
export const PASSPORT_STATUS = {
|
15
17
|
VALID: 'valid',
|
16
18
|
REVOKED: 'revoked',
|
package/src/Util/index.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
/* eslint-disable no-bitwise */
|
2
2
|
import padStart from 'lodash/padStart';
|
3
3
|
import { getDIDMotifInfo, colors } from '@arcblock/did-motif';
|
4
|
+
import { DID_PREFIX } from './constant';
|
4
5
|
|
5
6
|
let dateTool = null;
|
6
7
|
|
@@ -276,7 +277,7 @@ export const getFontSize = (size) => {
|
|
276
277
|
|
277
278
|
// 参考: asset-chain @arcblock/did
|
278
279
|
export const isEthereumDid = (did) => {
|
279
|
-
const address = did.replace(
|
280
|
+
const address = did.replace(DID_PREFIX, '');
|
280
281
|
// check if it has the basic requirements of an address
|
281
282
|
if (!/^(0x)?[0-9a-f]{40}$/i.test(address)) {
|
282
283
|
return false;
|