@arcblock/ux 1.16.16 → 1.16.17
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/NFTDisplay/index.js +17 -12
- package/package.json +4 -4
- package/src/NFTDisplay/index.js +15 -9
package/lib/NFTDisplay/index.js
CHANGED
|
@@ -56,11 +56,10 @@ function fromBase64(v) {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
return Buffer.from(_base64Url.default.unescape(v), 'base64');
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}; // 仅针对非 url type 的情况
|
|
59
|
+
} // const isVC = type => {
|
|
60
|
+
// return String(type).includes('VerifiableCredential');
|
|
61
|
+
// };
|
|
62
|
+
// 仅针对非 url type 的情况
|
|
64
63
|
|
|
65
64
|
|
|
66
65
|
const getSvgEmbedder = preferredSvgEmbedder => {
|
|
@@ -111,8 +110,7 @@ function NFTDisplay(_ref) {
|
|
|
111
110
|
}
|
|
112
111
|
|
|
113
112
|
const {
|
|
114
|
-
vcId
|
|
115
|
-
type: assetType
|
|
113
|
+
vcId
|
|
116
114
|
} = parsed.current;
|
|
117
115
|
const display = (0, _get.default)(parsed.current, 'credentialSubject.display');
|
|
118
116
|
const {
|
|
@@ -142,10 +140,9 @@ function NFTDisplay(_ref) {
|
|
|
142
140
|
if (!state.loading && minimumLoadingReady || state.error) {
|
|
143
141
|
onCompleted();
|
|
144
142
|
}
|
|
145
|
-
}, [state, minimumLoadingReady]);
|
|
143
|
+
}, [state, minimumLoadingReady]);
|
|
146
144
|
|
|
147
|
-
|
|
148
|
-
if (state.error || !isVC(assetType)) {
|
|
145
|
+
if (state.error) {
|
|
149
146
|
throw new Error('Failed to render NFT Display.');
|
|
150
147
|
}
|
|
151
148
|
|
|
@@ -153,10 +150,18 @@ function NFTDisplay(_ref) {
|
|
|
153
150
|
if (content) {
|
|
154
151
|
switch (type) {
|
|
155
152
|
case 'url':
|
|
153
|
+
case 'uri':
|
|
156
154
|
{
|
|
157
155
|
const urlObj = new URL(content);
|
|
158
|
-
|
|
159
|
-
urlObj.searchParams.
|
|
156
|
+
|
|
157
|
+
if (!urlObj.searchParams.has('assetId')) {
|
|
158
|
+
urlObj.searchParams.append('assetId', address);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (!urlObj.searchParams.has('vcId')) {
|
|
162
|
+
urlObj.searchParams.append('vcId', vcId);
|
|
163
|
+
}
|
|
164
|
+
|
|
160
165
|
const url = urlObj.href;
|
|
161
166
|
return /*#__PURE__*/_react.default.createElement("img", {
|
|
162
167
|
src: url,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/ux",
|
|
3
|
-
"version": "1.16.
|
|
3
|
+
"version": "1.16.17",
|
|
4
4
|
"description": "Common used react components for arcblock products",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -53,10 +53,10 @@
|
|
|
53
53
|
"react": ">=16.12.0",
|
|
54
54
|
"react-ga": "^2.7.0"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "4feaf12ac23b3a1db36f43bb0e05108f343753e6",
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@arcblock/icons": "^1.16.
|
|
59
|
-
"@arcblock/react-hooks": "^1.16.
|
|
58
|
+
"@arcblock/icons": "^1.16.17",
|
|
59
|
+
"@arcblock/react-hooks": "^1.16.17",
|
|
60
60
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
61
61
|
"@material-ui/core": "^4.12.3",
|
|
62
62
|
"@material-ui/icons": "4.11.2",
|
package/src/NFTDisplay/index.js
CHANGED
|
@@ -19,9 +19,9 @@ function fromBase64(v) {
|
|
|
19
19
|
return Buffer.from(base64.unescape(v), 'base64');
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
const isVC = type => {
|
|
23
|
-
|
|
24
|
-
};
|
|
22
|
+
// const isVC = type => {
|
|
23
|
+
// return String(type).includes('VerifiableCredential');
|
|
24
|
+
// };
|
|
25
25
|
|
|
26
26
|
// 仅针对非 url type 的情况
|
|
27
27
|
const getSvgEmbedder = preferredSvgEmbedder => {
|
|
@@ -65,7 +65,7 @@ function NFTDisplay({
|
|
|
65
65
|
parsed.current = JSON.parse(data);
|
|
66
66
|
// console.log('[debug] parse data')
|
|
67
67
|
}
|
|
68
|
-
const { vcId
|
|
68
|
+
const { vcId } = parsed.current;
|
|
69
69
|
const display = get(parsed.current, 'credentialSubject.display');
|
|
70
70
|
const { content, type } = display;
|
|
71
71
|
const isUrlType = type === 'url';
|
|
@@ -90,18 +90,24 @@ function NFTDisplay({
|
|
|
90
90
|
}
|
|
91
91
|
}, [state, minimumLoadingReady]);
|
|
92
92
|
|
|
93
|
-
|
|
94
|
-
if (state.error || !isVC(assetType)) {
|
|
93
|
+
if (state.error) {
|
|
95
94
|
throw new Error('Failed to render NFT Display.');
|
|
96
95
|
}
|
|
97
96
|
|
|
98
97
|
const renderNFT = () => {
|
|
99
98
|
if (content) {
|
|
100
99
|
switch (type) {
|
|
101
|
-
case 'url':
|
|
100
|
+
case 'url':
|
|
101
|
+
case 'uri': {
|
|
102
102
|
const urlObj = new URL(content);
|
|
103
|
-
urlObj.searchParams.
|
|
104
|
-
|
|
103
|
+
if (!urlObj.searchParams.has('assetId')) {
|
|
104
|
+
urlObj.searchParams.append('assetId', address);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (!urlObj.searchParams.has('vcId')) {
|
|
108
|
+
urlObj.searchParams.append('vcId', vcId);
|
|
109
|
+
}
|
|
110
|
+
|
|
105
111
|
const url = urlObj.href;
|
|
106
112
|
return (
|
|
107
113
|
<img
|