@stellar-expert/ui-framework 1.21.0 → 1.21.2

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,29 +1,29 @@
1
- import React from 'react'
2
- import PropTypes from 'prop-types'
3
- import cn from 'classnames'
4
- import {normalizeDate, formatDateUTC} from '@stellar-expert/formatter'
5
- import {BlockSelect} from '../interaction/block-select'
6
-
7
- export const UtcTimestamp = React.memo(function UtcTimestamp({date, dateOnly, className}) {
8
- let formatted
9
- try {
10
- date = normalizeDate(date)
11
- formatted = formatDateUTC(date)
12
- if (dateOnly) {
13
- formatted = formatted.split(' ')[0]
14
- } else {
15
- formatted += ' UTC'
16
- }
17
- } catch (e) {
18
- console.error(e)
19
- return null
20
- }
21
- const localTime = date.toString().replace(/ \(.+\)/, '').replace(/\w+ /, '')
22
- return <BlockSelect className={cn('condensed nowrap', className)} title={localTime}>{formatted}</BlockSelect>
23
- })
24
-
25
- UtcTimestamp.propTypes = {
26
- date: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.instanceOf(Date)]).isRequired,
27
- dateOnly: PropTypes.bool,
28
- className: PropTypes.string
1
+ import React from 'react'
2
+ import PropTypes from 'prop-types'
3
+ import cn from 'classnames'
4
+ import {normalizeDate, formatDateUTC} from '@stellar-expert/formatter'
5
+ import {BlockSelect} from '../interaction/block-select'
6
+
7
+ export const UtcTimestamp = React.memo(function UtcTimestamp({date, dateOnly, className}) {
8
+ let formatted
9
+ try {
10
+ date = normalizeDate(date)
11
+ formatted = formatDateUTC(date)
12
+ if (dateOnly) {
13
+ formatted = formatted.split(' ')[0]
14
+ } else {
15
+ formatted += ' UTC'
16
+ }
17
+ } catch (e) {
18
+ console.error(e)
19
+ return null
20
+ }
21
+ const localTime = date.toString().replace(/ \(.+\)/, '').replace(/\w+ /, '')
22
+ return <BlockSelect className={cn('condensed nowrap', className)} title={localTime}>{formatted}</BlockSelect>
23
+ })
24
+
25
+ UtcTimestamp.propTypes = {
26
+ date: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.instanceOf(Date)]).isRequired,
27
+ dateOnly: PropTypes.bool,
28
+ className: PropTypes.string
29
29
  }
@@ -1,58 +1,58 @@
1
- import React from 'react'
2
- import cn from 'classnames'
3
- import {EffectDescription} from './effect-description'
4
- import SorobanTxMetricsView from './soroban-tx-metrics-view'
5
- import './op-effects.scss'
6
-
7
- export function OpEffectsView({operation}) {
8
- const effects = getEffects(operation)
9
- if (!effects.length)
10
- return <div className="op-effects">
11
- <div className="dimmed">(no effects)</div>
12
- </div>
13
- return <div className="op-effects">
14
- {effects.map((e, i) => {
15
- if (e.type === 'contractMetrics')
16
- return null
17
- return <div key={i}>
18
- <i className={cn('effect-icon', e.type === 'contractError' ? 'icon-warning' : 'icon-puzzle')}/>&thinsp;
19
- <EffectDescription effect={e} operation={operation}/>
20
- </div>
21
- })}
22
- <SorobanTxMetricsView metrics={effects.find(e => e.type === 'contractMetrics')}/>
23
- </div>
24
- }
25
-
26
- function getEffects(op) {
27
- let {effects} = op.operation
28
- if (op.operation.type === 'invokeHostFunction')
29
- return sortContractEffects([...effects])
30
- return effects
31
- }
32
-
33
- function sortContractEffects(effects) {
34
- effects.sort((a, b) => {
35
- const aInvocation = a.type === 'contractInvoked'
36
- const bInvocation = b.type === 'contractInvoked'
37
- if (aInvocation && bInvocation)
38
- return 0
39
- if (!aInvocation && !bInvocation) {
40
- const aData = a.type === 'setTtl' || a.type.startsWith('contractData')
41
- const bData = b.type === 'setTtl' || b.type.startsWith('contractData')
42
- if (aData === bData) {
43
- if (a.type === 'setTtl')
44
- return 1
45
- if (b.type === 'setTtl')
46
- return -1
47
- if (a.durability === 'instance' && a.durability !== b.durability)
48
- return -1
49
- if (b.durability === 'instance' && a.durability !== b.durability)
50
- return 1
51
- return 0
52
- }
53
- return aData ? 1 : -1
54
- }
55
- return aInvocation ? -1 : 1
56
- })
57
- return effects
1
+ import React from 'react'
2
+ import cn from 'classnames'
3
+ import {EffectDescription} from './effect-description'
4
+ import SorobanTxMetricsView from './soroban-tx-metrics-view'
5
+ import './op-effects.scss'
6
+
7
+ export function OpEffectsView({operation}) {
8
+ const effects = getEffects(operation)
9
+ if (!effects.length)
10
+ return <div className="op-effects">
11
+ <div className="dimmed">(no effects)</div>
12
+ </div>
13
+ return <div className="op-effects">
14
+ {effects.map((e, i) => {
15
+ if (e.type === 'contractMetrics')
16
+ return null
17
+ return <div key={i}>
18
+ <i className={cn('effect-icon', e.type === 'contractError' ? 'icon-warning' : 'icon-puzzle')}/>&thinsp;
19
+ <EffectDescription effect={e} operation={operation}/>
20
+ </div>
21
+ })}
22
+ <SorobanTxMetricsView metrics={effects.find(e => e.type === 'contractMetrics')}/>
23
+ </div>
24
+ }
25
+
26
+ function getEffects(op) {
27
+ let {effects} = op.operation
28
+ if (op.operation.type === 'invokeHostFunction')
29
+ return sortContractEffects([...effects])
30
+ return effects
31
+ }
32
+
33
+ function sortContractEffects(effects) {
34
+ effects.sort((a, b) => {
35
+ const aInvocation = a.type === 'contractInvoked'
36
+ const bInvocation = b.type === 'contractInvoked'
37
+ if (aInvocation && bInvocation)
38
+ return 0
39
+ if (!aInvocation && !bInvocation) {
40
+ const aData = a.type === 'setTtl' || a.type.startsWith('contractData')
41
+ const bData = b.type === 'setTtl' || b.type.startsWith('contractData')
42
+ if (aData === bData) {
43
+ if (a.type === 'setTtl')
44
+ return 1
45
+ if (b.type === 'setTtl')
46
+ return -1
47
+ if (a.durability === 'instance' && a.durability !== b.durability)
48
+ return -1
49
+ if (b.durability === 'instance' && a.durability !== b.durability)
50
+ return 1
51
+ return 0
52
+ }
53
+ return aData ? 1 : -1
54
+ }
55
+ return aInvocation ? -1 : 1
56
+ })
57
+ return effects
58
58
  }
@@ -1,14 +1,14 @@
1
- import {AssetDescriptor} from '@stellar-expert/asset-descriptor'
2
- import {applyListQueryParameters, initHorizon} from './horizon-client-helpers'
3
-
4
- /**
5
- * Load orderbook for assets.
6
- * @param {object} selling - Selling asset.
7
- * @param {object} buying - Buying asset.
8
- * @param {ListQueryParams} [queryParams] - Query parameters (optional).
9
- * @return {Promise<Array<object>>}
10
- */
11
- export function loadOrderbook(selling, buying, queryParams = null) {
12
- const query = applyListQueryParameters(initHorizon().orderbook(AssetDescriptor.parse(selling).toAsset(), AssetDescriptor.parse(buying).toAsset()), queryParams)
13
- return query.call()
14
- }
1
+ import {AssetDescriptor} from '@stellar-expert/asset-descriptor'
2
+ import {applyListQueryParameters, initHorizon} from './horizon-client-helpers'
3
+
4
+ /**
5
+ * Load orderbook for assets.
6
+ * @param {object} selling - Selling asset.
7
+ * @param {object} buying - Buying asset.
8
+ * @param {ListQueryParams} [queryParams] - Query parameters (optional).
9
+ * @return {Promise<Array<object>>}
10
+ */
11
+ export function loadOrderbook(selling, buying, queryParams = null) {
12
+ const query = applyListQueryParameters(initHorizon().orderbook(AssetDescriptor.parse(selling).toAsset(), AssetDescriptor.parse(buying).toAsset()), queryParams)
13
+ return query.call()
14
+ }
package/package.json CHANGED
@@ -1,10 +1,9 @@
1
1
  {
2
2
  "name": "@stellar-expert/ui-framework",
3
- "version": "1.21.0",
3
+ "version": "1.21.2",
4
4
  "description": "StellarExpert shared UI components library",
5
5
  "author": "orbitlens <orbit@stellar.expert>",
6
6
  "license": "MIT",
7
- "type": "module",
8
7
  "main": "index.js",
9
8
  "module": "./index.js",
10
9
  "types": "index.d.ts",
@@ -21,7 +20,7 @@
21
20
  "@stellar-expert/asset-descriptor": "^2.0.0",
22
21
  "@stellar-expert/claimable-balance-utils": "^2.0.0",
23
22
  "@stellar-expert/client-cache": "^1.1.0",
24
- "@stellar-expert/contract-wasm-interface-parser": "^5.0.0",
23
+ "@stellar-expert/contract-wasm-interface-parser": "^5.0.1",
25
24
  "@stellar-expert/formatter": "^3.1.0",
26
25
  "@stellar-expert/navigation": "^1.1.0",
27
26
  "@stellar-expert/tx-meta-effects-parser": "^9.3.0",
@@ -1,27 +1,27 @@
1
- import React from 'react'
2
- import {Amount} from '../asset/amount'
3
- import {retrieveOpBalanceChanges} from './parser/op-balance-changes'
4
-
5
- /**
6
- * Compact accounting effects (credited/debited amounts)
7
- * @param {OperationDescriptor} op
8
- * @constructor
9
- */
10
- export function OpAccountingChanges({op}) {
11
- const changes = retrieveOpBalanceChanges(op)
12
- return <div className="accounting-effects condensed">
13
- {changes.map((ch, i) => <div key={op.txHash + op.order + i}
14
- className={ch.type === 'accountDebited' ? 'dimmed' : 'color-success'}>
15
- {ch.type === 'accountDebited' ? '-' : '+'}
16
- <Amount amount={ch.amount} asset={ch.asset} issuer={false} icon={false} adjust/>
17
- </div>)}
18
- </div>
19
- }
20
-
21
- export function TxFeeAccountingChanges({amount}) {
22
- return <div className="accounting-effects condensed">
23
- <div className="dimmed">
24
- -<Amount amount={amount} asset="XLM" issuer={false} icon={false} adjust/>
25
- </div>
26
- </div>
1
+ import React from 'react'
2
+ import {Amount} from '../asset/amount'
3
+ import {retrieveOpBalanceChanges} from './parser/op-balance-changes'
4
+
5
+ /**
6
+ * Compact accounting effects (credited/debited amounts)
7
+ * @param {OperationDescriptor} op
8
+ * @constructor
9
+ */
10
+ export function OpAccountingChanges({op}) {
11
+ const changes = retrieveOpBalanceChanges(op)
12
+ return <div className="accounting-effects condensed">
13
+ {changes.map((ch, i) => <div key={op.txHash + op.order + i}
14
+ className={ch.type === 'accountDebited' ? 'dimmed' : 'color-success'}>
15
+ {ch.type === 'accountDebited' ? '-' : '+'}
16
+ <Amount amount={ch.amount} asset={ch.asset} issuer={false} icon={false} adjust/>
17
+ </div>)}
18
+ </div>
19
+ }
20
+
21
+ export function TxFeeAccountingChanges({amount}) {
22
+ return <div className="accounting-effects condensed">
23
+ <div className="dimmed">
24
+ -<Amount amount={amount} asset="XLM" issuer={false} icon={false} adjust/>
25
+ </div>
26
+ </div>
27
27
  }
@@ -1,14 +1,14 @@
1
- import React from 'react'
2
- import {Amount} from '../asset/amount'
3
- import {fromStroops} from '@stellar-expert/formatter'
4
-
5
- export default function TxFeeEffect({feeEffect, compact}) {
6
- const {charged, bid, bump} = feeEffect
7
- if (charged)
8
- return <div>
9
- <Amount amount={fromStroops(charged)} asset="XLM" issuer={!compact}/> transaction {!!bump && 'bump'} fee charged
10
- </div>
11
- return <div>
12
- Charge transaction {!!bump && 'bump'} fee <Amount amount={fromStroops(bid)} asset="XLM" issuer={!compact}/>
13
- </div>
1
+ import React from 'react'
2
+ import {Amount} from '../asset/amount'
3
+ import {fromStroops} from '@stellar-expert/formatter'
4
+
5
+ export default function TxFeeEffect({feeEffect, compact}) {
6
+ const {charged, bid, bump} = feeEffect
7
+ if (charged)
8
+ return <div>
9
+ <Amount amount={fromStroops(charged)} asset="XLM" issuer={!compact}/> transaction {!!bump && 'bump'} fee charged
10
+ </div>
11
+ return <div>
12
+ Charge transaction {!!bump && 'bump'} fee <Amount amount={fromStroops(bid)} asset="XLM" issuer={!compact}/>
13
+ </div>
14
14
  }