@stellar-expert/ui-framework 1.16.4 → 1.16.5

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,5 +1,6 @@
1
1
  import React from 'react'
2
2
  import {AssetDescriptor} from '@stellar-expert/asset-descriptor'
3
+ import {drawIdenticon} from '../account/identicon'
3
4
  import {useAssetMeta} from './asset-meta-hooks'
4
5
 
5
6
  /**
@@ -12,6 +13,9 @@ import {useAssetMeta} from './asset-meta-hooks'
12
13
  */
13
14
  export const AssetIcon = React.memo(function AssetIcon({asset, className, style, children}) {
14
15
  const meta = useAssetMeta(asset)
16
+ if (typeof asset === 'string') {
17
+ asset = AssetDescriptor.parse(asset)
18
+ }
15
19
  const icon = meta?.toml_info?.image || meta?.toml_info?.orgLogo
16
20
  const classes = ['asset-icon']
17
21
  if (!style) {
@@ -22,10 +26,13 @@ export const AssetIcon = React.memo(function AssetIcon({asset, className, style,
22
26
  classes.push(className)
23
27
  }
24
28
 
25
- if (asset.toString() === 'XLM') { // native asset
29
+ if (asset.isNative) { // native asset
26
30
  classes.push('icon icon-stellar')
27
31
  } else if (icon) { // asset with an icon
28
32
  style.backgroundImage = `url('${icon}')`
33
+ } else if (asset.isContract) {
34
+ style.backgroundImage = `url('${'data:image/svg+xml;charset=utf-8,' + drawIdenticon(asset.toString())}')`
35
+ style.borderRadius = '50%'
29
36
  } else { // asset without metadata
30
37
  classes.push('icon icon-empty-circle')
31
38
  }
@@ -65,10 +65,10 @@ export const AssetLink = React.memo(function AssetLink({
65
65
  } else if (asset.isContract) {
66
66
  children = <>
67
67
  <AssetWarningStatus meta={meta}/>
68
- {!!meta?.code && <>{meta.code} </>}
68
+ {icon !== false && <AssetIcon asset={asset}/>}
69
+ {!!meta?.code && <span title={meta.tokenName}>{meta.code} </span>}
69
70
  {(issuer !== false || !meta?.code) &&
70
- <AccountAddress account={asset.contract} chars={8} link={false} icon={!!icon}
71
- title={meta?.tokenName}/>}
71
+ <AccountAddress account={asset.contract} chars={8} link={false} icon={false}/>}
72
72
  </>
73
73
  } else {
74
74
  children = <>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stellar-expert/ui-framework",
3
- "version": "1.16.4",
3
+ "version": "1.16.5",
4
4
  "description": "StellarExpert shared UI components library",
5
5
  "main": "index.js",
6
6
  "module": "./index.js",