@arcblock/ux 2.9.61 → 2.9.63

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.
@@ -111,7 +111,7 @@ const DidAddress = /*#__PURE__*/forwardRef(({
111
111
  component: "span",
112
112
  className: "did-address-text",
113
113
  sx: {
114
- cursor: copyable ? 'text' : 'pointer'
114
+ cursor: copyable ? 'unset' : 'pointer'
115
115
  },
116
116
  onDoubleClick: copyable ? noop : onCopy,
117
117
  children: /*#__PURE__*/_jsx(CompactText, {
@@ -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('did:abt:', '').toLowerCase(),
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('did:abt:', ''),
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
- if (!translations[locale]) {
83
- // eslint-disable-next-line no-param-reassign
84
- locale = 'en';
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;
@@ -129,14 +135,40 @@ const DID = /*#__PURE__*/forwardRef(({
129
135
  const closeQrCode = useMemoizedFn(() => {
130
136
  setOpen(false);
131
137
  });
132
- const openQrCode = useMemoizedFn(() => {
138
+ const openQrCode = useMemoizedFn(e => {
139
+ e.stopPropagation();
140
+ e.preventDefault();
133
141
  setOpen(true);
134
142
  });
143
+ const downloadUrl = useCreation(() => {
144
+ if (['zh', 'en'].includes) {
145
+ return `https://www.didwallet.io/${locale}`;
146
+ }
147
+ return 'https://www.didwallet.io/en';
148
+ }, [locale]);
149
+ const downloadTips = useCreation(() => {
150
+ return /*#__PURE__*/_jsxs(_Fragment, {
151
+ children: [t('downloadTips'), ' ', /*#__PURE__*/_jsx(Box, {
152
+ component: "a",
153
+ href: downloadUrl,
154
+ target: "_blank",
155
+ rel: "noreferrer",
156
+ sx: {
157
+ color: colors.foregroundsFgInteractive,
158
+ textDecoration: 'none',
159
+ '&:hover': {
160
+ textDecoration: 'underline'
161
+ }
162
+ },
163
+ children: t('download')
164
+ })]
165
+ });
166
+ }, [downloadUrl]);
135
167
  return /*#__PURE__*/_jsxs(_Fragment, {
136
168
  children: [/*#__PURE__*/_jsx(Address, {
137
169
  ref: ref,
138
170
  locale: locale,
139
- content: `did:abt:${did}`,
171
+ content: `${DID_PREFIX}${did}`,
140
172
  ...rest,
141
173
  prepend: prepend,
142
174
  append: showQrcode ? /*#__PURE__*/_jsx(Box, {
@@ -156,22 +188,17 @@ const DID = /*#__PURE__*/forwardRef(({
156
188
  maxWidth: "sm",
157
189
  children: [/*#__PURE__*/_jsx(DialogTitle, {
158
190
  align: "center",
159
- children: /*#__PURE__*/_jsx(Box, {
160
- display: "inline-block",
161
- pt: 1.5,
162
- fontSize: {
163
- xs: 13,
164
- sm: 'inherit'
165
- },
166
- component: "span",
167
- children: translations[locale].scanQrcode
191
+ children: /*#__PURE__*/_jsx(Typography, {
192
+ variant: "h6",
193
+ component: "h3",
194
+ children: t('scanQrcode')
168
195
  })
169
196
  }), /*#__PURE__*/_jsxs(DialogContent, {
170
197
  align: "center",
171
198
  children: [/*#__PURE__*/_jsx(QRCode
172
199
  // eslint-disable-next-line max-len
173
200
  , {
174
- value: `abt://abtwallet.io/i?did=did:abt:${did}&action=didRecognize&chainID=${chainId || DEFAULT_CHAIN_ID}`,
201
+ value: `abt://abtwallet.io/i?did=${DID_PREFIX}${did}&action=didRecognize&chainID=${chainId || DEFAULT_CHAIN_ID}`,
175
202
  size: 256,
176
203
  renderAs: "svg",
177
204
  level: "M"
@@ -183,9 +210,18 @@ const DID = /*#__PURE__*/forwardRef(({
183
210
  children: /*#__PURE__*/_jsx(Address, {
184
211
  copyable: true,
185
212
  locale: locale,
186
- content: `did:abt:${did}`,
213
+ content: `${DID_PREFIX}${did}`,
214
+ prepend: prepend,
187
215
  children: did
188
216
  })
217
+ }), /*#__PURE__*/_jsx(Typography, {
218
+ variant: "body2",
219
+ sx: {
220
+ color: colors.textSubtitle,
221
+ fontSize: '12px',
222
+ mt: 1
223
+ },
224
+ children: downloadTips
189
225
  })]
190
226
  })]
191
227
  })]
@@ -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('did:abt:', '');
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;
@@ -130,7 +130,7 @@ const DidAddress = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
130
130
  component: "span",
131
131
  className: "did-address-text",
132
132
  sx: {
133
- cursor: copyable ? 'text' : 'pointer'
133
+ cursor: copyable ? 'unset' : 'pointer'
134
134
  },
135
135
  onDoubleClick: copyable ? _noop.default : onCopy,
136
136
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_compactText.default, {
@@ -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('did:abt:', '').toLowerCase(),
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('did:abt:', ''),
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
- if (!translations[locale]) {
97
- // eslint-disable-next-line no-param-reassign
98
- locale = 'en';
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;
@@ -144,14 +151,40 @@ const DID = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
144
151
  const closeQrCode = (0, _ahooks.useMemoizedFn)(() => {
145
152
  setOpen(false);
146
153
  });
147
- const openQrCode = (0, _ahooks.useMemoizedFn)(() => {
154
+ const openQrCode = (0, _ahooks.useMemoizedFn)(e => {
155
+ e.stopPropagation();
156
+ e.preventDefault();
148
157
  setOpen(true);
149
158
  });
159
+ const downloadUrl = (0, _ahooks.useCreation)(() => {
160
+ if (['zh', 'en'].includes) {
161
+ return "https://www.didwallet.io/".concat(locale);
162
+ }
163
+ return 'https://www.didwallet.io/en';
164
+ }, [locale]);
165
+ const downloadTips = (0, _ahooks.useCreation)(() => {
166
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
167
+ children: [t('downloadTips'), ' ', /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
168
+ component: "a",
169
+ href: downloadUrl,
170
+ target: "_blank",
171
+ rel: "noreferrer",
172
+ sx: {
173
+ color: _Colors.temp.foregroundsFgInteractive,
174
+ textDecoration: 'none',
175
+ '&:hover': {
176
+ textDecoration: 'underline'
177
+ }
178
+ },
179
+ children: t('download')
180
+ })]
181
+ });
182
+ }, [downloadUrl]);
150
183
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
151
184
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Address.default, _objectSpread(_objectSpread({
152
185
  ref: ref,
153
186
  locale: locale,
154
- content: "did:abt:".concat(did)
187
+ content: "".concat(_constant.DID_PREFIX).concat(did)
155
188
  }, rest), {}, {
156
189
  prepend: prepend,
157
190
  append: showQrcode ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
@@ -171,22 +204,17 @@ const DID = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
171
204
  maxWidth: "sm",
172
205
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.DialogTitle, {
173
206
  align: "center",
174
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
175
- display: "inline-block",
176
- pt: 1.5,
177
- fontSize: {
178
- xs: 13,
179
- sm: 'inherit'
180
- },
181
- component: "span",
182
- children: translations[locale].scanQrcode
207
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
208
+ variant: "h6",
209
+ component: "h3",
210
+ children: t('scanQrcode')
183
211
  })
184
212
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.DialogContent, {
185
213
  align: "center",
186
214
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_qrcode.default
187
215
  // eslint-disable-next-line max-len
188
216
  , {
189
- value: "abt://abtwallet.io/i?did=did:abt:".concat(did, "&action=didRecognize&chainID=").concat(chainId || DEFAULT_CHAIN_ID),
217
+ value: "abt://abtwallet.io/i?did=".concat(_constant.DID_PREFIX).concat(did, "&action=didRecognize&chainID=").concat(chainId || DEFAULT_CHAIN_ID),
190
218
  size: 256,
191
219
  renderAs: "svg",
192
220
  level: "M"
@@ -198,9 +226,18 @@ const DID = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
198
226
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Address.default, {
199
227
  copyable: true,
200
228
  locale: locale,
201
- content: "did:abt:".concat(did),
229
+ content: "".concat(_constant.DID_PREFIX).concat(did),
230
+ prepend: prepend,
202
231
  children: did
203
232
  })
233
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
234
+ variant: "body2",
235
+ sx: {
236
+ color: _Colors.temp.textSubtitle,
237
+ fontSize: '12px',
238
+ mt: 1
239
+ },
240
+ children: downloadTips
204
241
  })]
205
242
  })]
206
243
  })]
@@ -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('did:abt:', '');
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.61",
3
+ "version": "2.9.63",
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": "2349446884f18459b909c2dfe32f4411554f83da",
361
+ "gitHead": "e5e083300891c1ff349c653a70229ea6ba3f8b24",
362
362
  "dependencies": {
363
363
  "@arcblock/did-motif": "^1.1.13",
364
- "@arcblock/icons": "^2.9.61",
365
- "@arcblock/nft-display": "^2.9.61",
366
- "@arcblock/react-hooks": "^2.9.61",
364
+ "@arcblock/icons": "^2.9.63",
365
+ "@arcblock/nft-display": "^2.9.63",
366
+ "@arcblock/react-hooks": "^2.9.63",
367
367
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
368
368
  "@emotion/react": "^11.10.4",
369
369
  "@emotion/styled": "^11.10.4",
@@ -102,7 +102,7 @@ const DidAddress = forwardRef(
102
102
  component="span"
103
103
  className="did-address-text"
104
104
  sx={{
105
- cursor: copyable ? 'text' : 'pointer',
105
+ cursor: copyable ? 'unset' : 'pointer',
106
106
  }}
107
107
  onDoubleClick={copyable ? noop : onCopy}>
108
108
  <CompactText
@@ -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('did:abt:', '').toLowerCase(),
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('did:abt:', '')}
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
- if (!translations[locale]) {
81
- // eslint-disable-next-line no-param-reassign
82
- locale = 'en';
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) {
@@ -121,16 +127,47 @@ const DID = forwardRef(({ did, showAvatar, showQrcode, chainId, locale, ...rest
121
127
  const closeQrCode = useMemoizedFn(() => {
122
128
  setOpen(false);
123
129
  });
124
- const openQrCode = useMemoizedFn(() => {
130
+ const openQrCode = useMemoizedFn((e) => {
131
+ e.stopPropagation();
132
+ e.preventDefault();
125
133
  setOpen(true);
126
134
  });
127
135
 
136
+ const downloadUrl = useCreation(() => {
137
+ if (['zh', 'en'].includes) {
138
+ return `https://www.didwallet.io/${locale}`;
139
+ }
140
+ return 'https://www.didwallet.io/en';
141
+ }, [locale]);
142
+
143
+ const downloadTips = useCreation(() => {
144
+ return (
145
+ <>
146
+ {t('downloadTips')}{' '}
147
+ <Box
148
+ component="a"
149
+ href={downloadUrl}
150
+ target="_blank"
151
+ rel="noreferrer"
152
+ sx={{
153
+ color: colors.foregroundsFgInteractive,
154
+ textDecoration: 'none',
155
+ '&:hover': {
156
+ textDecoration: 'underline',
157
+ },
158
+ }}>
159
+ {t('download')}
160
+ </Box>
161
+ </>
162
+ );
163
+ }, [downloadUrl]);
164
+
128
165
  return (
129
166
  <>
130
167
  <Address
131
168
  ref={ref}
132
169
  locale={locale}
133
- content={`did:abt:${did}`}
170
+ content={`${DID_PREFIX}${did}`}
134
171
  {...rest}
135
172
  prepend={prepend}
136
173
  append={
@@ -152,23 +189,34 @@ const DID = forwardRef(({ did, showAvatar, showQrcode, chainId, locale, ...rest
152
189
 
153
190
  <Dialog open={open} onClose={closeQrCode} maxWidth="sm">
154
191
  <DialogTitle align="center">
155
- <Box display="inline-block" pt={1.5} fontSize={{ xs: 13, sm: 'inherit' }} component="span">
156
- {translations[locale].scanQrcode}
157
- </Box>
192
+ <Typography variant="h6" component="h3">
193
+ {t('scanQrcode')}
194
+ </Typography>
158
195
  </DialogTitle>
159
196
  <DialogContent align="center">
160
197
  <QRCode
161
198
  // eslint-disable-next-line max-len
162
- value={`abt://abtwallet.io/i?did=did:abt:${did}&action=didRecognize&chainID=${chainId || DEFAULT_CHAIN_ID}`}
199
+ value={`abt://abtwallet.io/i?did=${DID_PREFIX}${did}&action=didRecognize&chainID=${
200
+ chainId || DEFAULT_CHAIN_ID
201
+ }`}
163
202
  size={256}
164
203
  renderAs="svg"
165
204
  level="M"
166
205
  />
167
206
  <Box sx={{ marginTop: 1, textAlign: 'center' }}>
168
- <Address copyable locale={locale} content={`did:abt:${did}`}>
207
+ <Address copyable locale={locale} content={`${DID_PREFIX}${did}`} prepend={prepend}>
169
208
  {did}
170
209
  </Address>
171
210
  </Box>
211
+ <Typography
212
+ variant="body2"
213
+ sx={{
214
+ color: colors.textSubtitle,
215
+ fontSize: '12px',
216
+ mt: 1,
217
+ }}>
218
+ {downloadTips}
219
+ </Typography>
172
220
  </DialogContent>
173
221
  </Dialog>
174
222
  </>
@@ -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('did:abt:', '');
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;