@stellar-expert/ui-framework 1.16.1 → 1.16.3

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.
@@ -21,7 +21,15 @@ import './asset-link.scss'
21
21
  * @param {*} [children] - Optional inner link text
22
22
  * @constructor
23
23
  */
24
- export const AssetLink = React.memo(function AssetLink({asset, link, issuer, icon, className, style, children: innerText}) {
24
+ export const AssetLink = React.memo(function AssetLink({
25
+ asset,
26
+ link,
27
+ issuer,
28
+ icon,
29
+ className,
30
+ style,
31
+ children: innerText
32
+ }) {
25
33
  if (!(asset instanceof AssetDescriptor)) {
26
34
  asset = AssetDescriptor.parse(asset)
27
35
  }
@@ -54,12 +62,19 @@ export const AssetLink = React.memo(function AssetLink({asset, link, issuer, ico
54
62
  } else {
55
63
  children = <>{shortenString(asset.poolId)}</>
56
64
  }
65
+ } else if (asset.isContract) {
66
+ children = <>
67
+ <AssetWarningStatus meta={meta}/>
68
+ {!!meta.code && <>{meta.code} </>}
69
+ {(issuer !== false && !!meta.code) &&
70
+ <AccountAddress account={asset.contract} chars={8} link={false} icon={!!icon}
71
+ title={meta.tokenName}/>}
72
+ </>
57
73
  } else {
58
74
  children = <>
59
75
  <AssetWarningStatus meta={meta}/>
60
76
  {icon !== false && <AssetIcon asset={asset}/>}
61
77
  {!!asset.code && asset.code}
62
- {!!asset.isContract && <AccountAddress account={asset.contract} chars={8} link={false} icon={false}/>}
63
78
  {issuer !== false && <AssetIssuer asset={asset}/>}
64
79
  </>
65
80
  }
@@ -7,6 +7,14 @@ import {ExplorerBatchInfoLoader} from '../api/explorer-batch-info-loader'
7
7
 
8
8
  const cache = new InMemoryClientCache({})
9
9
 
10
+ function isValidAddress(address) {
11
+ if (!address)
12
+ return false
13
+ if (!StrKey.isValidEd25519PublicKey(address) && !StrKey.isValidContract(address))
14
+ return false
15
+ return true
16
+ }
17
+
10
18
  const loader = new ExplorerBatchInfoLoader(batch => {
11
19
  return fetchExplorerApi('directory' + stringifyQuery({address: batch}))
12
20
  }, entry => {
@@ -17,7 +25,8 @@ const loader = new ExplorerBatchInfoLoader(batch => {
17
25
  export async function getDirectoryEntry(address, options) {
18
26
  const {forceRefresh = false, extended = false} = options || {}
19
27
  //ignore invalid addresses
20
- if (!address || !StrKey.isValidEd25519PublicKey(address)) return null
28
+ if (!isValidAddress(address))
29
+ return null
21
30
  if (extended) {
22
31
  return fetchExplorerApi(`directory/${address}` + stringifyQuery({
23
32
  extended: true,
@@ -48,7 +57,7 @@ export function useDirectory(address, options) {
48
57
  const [directoryInfo, setDirectoryInfo] = useState(null)
49
58
  let unloaded = false
50
59
  useEffect(function () {
51
- if (!address || !(StrKey.isValidEd25519PublicKey(address) || StrKey.isValidContract(address)))
60
+ if (!isValidAddress(address))
52
61
  return
53
62
  if (!forceRefresh) {
54
63
  const cachedEntry = cache.get(address)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stellar-expert/ui-framework",
3
- "version": "1.16.1",
3
+ "version": "1.16.3",
4
4
  "description": "StellarExpert shared UI components library",
5
5
  "main": "index.js",
6
6
  "module": "./index.js",